KeyError:“无效的分割序列[:80%],可用的分割为:TensorFlow官方教程中的['train']”[副本]

5ktev3wc  于 2022-12-04  发布在  其他
关注(0)|答案(1)|浏览(183)

此问题在此处已有答案

Split train data to train and validation by using tensorflow_datasets.load (TF 2.1)(2个答案)
两年前就关门了。
位于Link:https://www.tensorflow.org/tutorials/images/transfer_learning
(raw_train, raw_validation, raw_test), metadata = tfds.load( 'cats_vs_dogs', split=['train[:80%]', 'train[80%:90%]', 'train[90%:]'], with_info=True, as_supervised=True, )
错误原因
KeyError: "Invalid split train[:80%]. Available splits are: ['train']"

h5qlskok

h5qlskok1#

试试这个代码我们可以在TF 2中将其拆分为:

(raw_train, raw_validation, raw_test), metadata = tfds.load(
'cats_vs_dogs',
split=[
   tfds.Split.TRAIN.subsplit(tfds.percent[:80]),
   tfds.Split.TRAIN.subsplit(tfds.percent[80:90]),
   tfds.Split.TRAIN.subsplit(tfds.percent[90:])
],
with_info=True,
as_supervised=True,
)

相关问题