KeyError: "Invalid split train[:80%]. Available splits are: ['train']" in TensorFlow official tutorial

Question:

At 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,
)

why there is an error

KeyError: "Invalid split train[:80%]. Available splits are: ['train']"

Asked By: SREERAG R NANDAN

||

Answers:

Try this code
We can split it in TF 2 as:

(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,
)
Answered By: SREERAG R NANDAN