简体   繁体   中英

How to use Keras ImageDataGenerator for own dataset, to train a convolutional autoencoder?

Could someone please tell me if ImageDataGenerator takes a random batch of original data while training, or does it take sequentially in every epoch, like the first 100 samples in the first iteration, the second 100 samples in the second iteration, and so on? I need to understand this as I'm training a convolutional autoencoder, and the input is passed as output too, in model.fit(). So both should correspond correctly.

The dataset has 3200 images of size 360x640. As of now, I have this:

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]

Looking here , you'll find

shuffle Whether to shuffle the data (default: True) If set to False, sorts the data in alphanumeric order.

As you've used shuffle=True explicitly in your code, it is guaranteed that the order is not reproducible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM