Я пробовал model.fit () и model.fit_generator (), но результат показывает, что model.fit () имеет лучший результат по сравнению с model.fit_generator (). Я хотел бы расширить обучающий набор, таким образом, я использовал ImageDataGenerator () и model.fit_generator (). Ниже приведен график с model.fit () и model.fit_generator (). 
Как видите, model.fit () имеет лучшую точность проверки и потери проверки по сравнению с model.fit_generator (). Ниже мой код CNN.
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=2)
model = Sequential()
# filters, kernel size, input size
model.add(Conv2D(32, (3, 3), activation='relu', input_shape=X.shape[1:], padding='Same'))
model.add(Conv2D(32, (3, 3), activation='relu', padding='Same'))
model.add(MaxPooling2D(pool_size=(2, 2), strides=2))
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), activation='relu', padding='Same'))
model.add(MaxPooling2D(pool_size=(2, 2), strides=2))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(BatchNormalization())
model.add(Dropout(0.5))
model.add(Dense(3, activation='softmax'))
tensorboard = TensorBoard(log_dir="CNN_Model_Rebuilt/logs/{}".format(NAME))
augmented_checkpoint = ModelCheckpoint(
'CNN_Model_Rebuilt/best model/' + NAME + '-best.h5',
monitor='val_loss', verbose=0,
save_best_only=True, mode='auto')
es = EarlyStopping(monitor='val_loss',
min_delta=0,
patience=20,
verbose=0, mode='auto')
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
datagen = ImageDataGenerator(
featurewise_center=False, # set input mean to 0 over the dataset
samplewise_center=False, # set each sample mean to 0
featurewise_std_normalization=False, # divide inputs by std of the dataset
samplewise_std_normalization=False, # divide each input by its std
zca_whitening=False, # apply ZCA whitening
rotation_range=10, # randomly rotate images in the range (degrees, 0 to 180)
zoom_range=0.1, # Randomly zoom image
width_shift_range=0.1, # randomly shift images horizontally (fraction of total width)
height_shift_range=0.1, # randomly shift images vertically (fraction of total height)
horizontal_flip=False, # randomly flip images
vertical_flip=False) # randomly flip images
datagen.fit(X_train)
epochs = 50
batchsize = 16
history = model.fit_generator(datagen.flow(X_train, to_categorical(y_train), batch_size=batchsize),
epochs=epochs, validation_data=(X_test, to_categorical(y_test)),
verbose=2, steps_per_epoch=X-train.shape[0], callbacks=
[augmented_checkpoint, tensorboard, es])
Есть ли у кода проблемы? Любое предложение будет благодарно. Спасибо.