Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Last active August 10, 2020 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniruddha27/2be45e9f494752b697470836288f7ad1 to your computer and use it in GitHub Desktop.
Save aniruddha27/2be45e9f494752b697470836288f7ad1 to your computer and use it in GitHub Desktop.
# Augmenting on the fly with fit_generator()
# Directly use .flow()
model.fit_generator(datagen.flow(x_train, y_train, batch_size=batch_size),
epochs=epochs, # one forward/backward pass of training data
steps_per_epoch=x_train.shape[0]//batch_size, # number of images comprising of one epoch
validation_data=(x_test, y_test), # data for validation
validation_steps=x_test.shape[0]//batch_size)
# or use iterator from .flow_from_directory()
model.fit_generator(train_generator,
epochs=epochs, # one forward/backward pass of training data
steps_per_epoch=x_train.shape[0]//batch_size, # number of images comprising of one epoch
validation_data=(x_test, y_test), # Or validation_data=valid_generator
validation_steps=x_test.shape[0]//batch_size)
# or use iterator from .flow_from_datafram()
model.fit_generator(train_generator_df,
epochs=epochs, # one forward/backward pass of training data
steps_per_epoch=x_train.shape[0]//batch_size, # number of images comprising of one epoch
validation_data=(x_test, y_test), # Or validation_data=valid_generator
validation_steps=x_test.shape[0]//batch_size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment