1in python 2:
2
3X_train, y_train = train_generator.next()
4X_test, y_test = validation_generator.next()
5
6in python 3:
7
8X_train, y_train = next(train_generator)
9X_test, y_test = next(validation_generator)
1train_datagen = ImageDataGenerator(rescale=1./255,
2 shear_range=0.2,
3 zoom_range=0.2,
4 horizontal_flip=True,
5 validation_split=0.2) # set validation split
6
7train_generator = train_datagen.flow_from_directory(
8 train_data_dir,
9 target_size=(img_height, img_width),
10 batch_size=batch_size,
11 class_mode='binary',
12 subset='training') # set as training data
13
14validation_generator = train_datagen.flow_from_directory(
15 train_data_dir, # same directory as training data
16 target_size=(img_height, img_width),
17 batch_size=batch_size,
18 class_mode='binary',
19 subset='validation') # set as validation data