我正在尝试通过在Keras中使用ImageDataGenerator拆分我的数据(图像),方法是将validation_split设置为某个分数。
这是我的代码
#Generate batches of tensor image data with real-time data augmentation,
looped over in batches
train_DataGen_Augmnt =ImageDataGenerator(
rescale=1./255,
featurewise_center=True,
validation_split=0.2,
rotation_range=30,
horizontal_flip=True,
)
#validation data not augmented!
Validation_DataGen = ImageDataGenerator(rescale=1./255)
# Flow training images in batches of 32 using train_datagen generator
train_generator = train_DataGen_Augmnt.flow_from_directory(
base_dir,
subset='training',
target_size=(150, 150),
batch_size=32,
#save_to_dir='images/Agumented'
)
# Flow validation images in batches of 32 using test_datagen generator
validation_generator = Validation_DataGen.flow_from_directory(
base_dir,
subset='validation',
target_size=(150, 150),
batch_size=32,
)
拆分似乎在拆分数据时起作用,但仅显示拆分信息仅供培训
这是运行此命令时的输出
Found 89 images belonging to 3 classes.
Found 0 images belonging to 3 classes.