Skip to content
Advertisement

How to extract validation data from training data

I have following statement

self.__Dir_Data = tf.keras.preprocessing.image_dataset_from_directory(self.__Dir_Path ,validation_split = 0.1 ,subset="training", seed = 1,  labels='inferred', label_mode='int' ,batch_size=32 ,image_size=(124, 124))

I would like to extract from following Dir Data, separate Validation Data

Greetings DA

Advertisement

Answer

in the call to image_dataset_from_directory, set subset=’training for the train dataset and set it to ‘validation’ for the validation set as shown below

train_data=tf.keras.preprocessing.image_dataset_from_directory(self.__Dir_Path ,validation_split = 0.1 ,subset="training", seed = 1,  labels='inferred', label_mode='int' ,batch_size=32 ,image_size=(124, 124))

validation_data=tf.keras.preprocessing.image_dataset_from_directory(self.__Dir_Path ,validation_split = 0.1 ,subset="validation", seed = 1,  labels='inferred', label_mode='int' ,batch_size=32 ,image_size=(124, 124))
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement