我想使用ImageDataGenerator加载图像,并使用validation_split
参数将它们分为训练和测试集。但是,我无法从Keras文档中了解分割是如何完成的(它是随机的吗?总是选择相同的图像吗?),或者我该如何播种以便再现分割。
到目前为止,这是我的代码:
# Create a keras data generator
from tensorflow.keras.preprocessing.image import ImageDataGenerator
datagen = ImageDataGenerator(validation_split=0.1, rescale=1./255)
train_generator = datagen.flow_from_directory(directory='poc_train_data/data', target_size=input_size, subset='training', class_mode='binary')
val_generator = datagen.flow_from_directory(directory='poc_train_data/data', target_size=input_size, subset='validation', class_mode='binary')
class_indices = train_generator.class_indices
index_to_class = {v:k for k,v in class_indices.items()}
如何修改它,使其始终产生相同的随机分割?