【问题标题】:How to use Keras ImageDataGenerator for own dataset, to train a convolutional autoencoder?如何将 Keras ImageDataGenerator 用于自己的数据集,以训练卷积自动编码器?
【发布时间】:2021-07-10 06:08:12
【问题描述】:

有人可以告诉我 ImageDataGenerator 是在训练时采用随机批次的原始数据,还是在每个 epoch 中按顺序采用,例如第一次迭代中的前 100 个样本,第二次迭代中的后 100 个样本,等等在? 我需要理解这一点,因为我正在训练一个卷积自动编码器,并且输入也作为输出在 model.fit() 中传递。所以两者都应该正确对应。

数据集有 3200 张大小为 360x640 的图像。截至目前,我有这个:

gen = ImageDataGenerator()
train_im = ImageDataGenerator(
               rescale=1./255,
               shear_range=0.2,
               horizontal_flip=False)
def train_images():
    train_generator = train_im.flow_from_directory (
            'train_frames', 
             target_size=(360, 640),
             color_mode='rgb',
             batch_size=100,
             shuffle = True,
             class_mode='categorical')
    x =  train_generator
    return x[0][0], x[0][1]

【问题讨论】:

    标签: python keras autoencoder


    【解决方案1】:

    查看here,你会发现

    shuffle是否打乱数据(默认:True)如果设置为False,则按字母数字顺序对数据进行排序。

    由于您在代码中明确使用了shuffle=True,因此可以保证该顺序不可重现。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-06
      • 2017-11-11
      • 2021-05-10
      • 1970-01-01
      • 1970-01-01
      • 2018-09-08
      • 1970-01-01
      相关资源
      最近更新 更多