如何从训练数据中提取验证数据

时间:2020-11-09 11:37:38

标签: python tensorflow keras

我有以下声明

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

我想从以下Dir数据中提取单独的验证数据

问候 DA

1 个答案:

答案 0 :(得分:1)

在对image_dataset_from_directory的调用中,为train数据集设置subset ='training,并为验证集将其设置为'validation',如下所示

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