我目前使用的是tensorflow.keras.preprocessing.image.ImageDataGenerator和flow_from_directory。例如:
from tensorflow.keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(rotation_range=20,
width_shift_range=0.1,
height_shift_range=0.1,
shear_range=0.2,
zoom_range=0.2,
fill_mode='nearest',
horizontal_flip=True,
rescale=1/255.0,
preprocessing_function=preprocessing_function,
data_format='channels_last')
train_generator = train_datagen.flow_from_directory(
directory=env.channel_dirs['train'],
target_size=(train_size, train_size),
color_mode="rgb",
batch_size=batch_size,
class_mode="categorical",
shuffle=True,
interpolation='bilinear',
seed=42)我发现即使在numpy和TensorFlow中都设置了种子,批处理顺序也不是静态的,所以我得不到可重现的结果。我看过推荐使用keras Sequence的this post。然而,它只有一个很小的例子。
是否有可能使ImageDataGenerator批量订单可重现?或者,有没有人可以分享一个例子,告诉我如何在使用Sequence的同时保留flow_from_directory,同时使用ImageDataGenerator的增强选项?如果一个例子要求太多,总结一下如何做到这一点也会非常感谢!
发布于 2019-01-13 11:54:51
这是一个nice-script,你也可以通过它来控制内部进程。这意味着,您可以定义自己在每次迭代中生成数据的方式,以及目录中的流动数据。
https://stackoverflow.com/questions/54164339
复制相似问题