0.2, # randomly shift images horizontally (fraction of total width) height_shift_range= 0.2, # randomly shift images vertically (fraction of total height) horizontal_flip=True, # randomly flip images vertical_flip=False) # randomly flip images datagen.fit(x_train) #train batch_size = 16 epochs = 30 if (options.validation): epochs = 50 History = model.fit_generator(datagen.flow(x_train, y_train, batch_size=batch_size), epochs=epochs, validation_data=(x_test, y_test), verbose=1, steps_per_epoch=x_train.shape[0] // batch_size) else: History = model.fit_generator(datagen.flow(x_train, y_train, batch_size=batch_size), epochs=epochs, verbose=1, steps_per_epoch=x_train.shape[0] // batch_size) #generate submission if (options.save_submission):
if remote_execution: class LogRunMetrics(Callback): # callback at the end of every epoch def on_epoch_end(self, epoch, log): # log a value repeated which creates a list run.log('val_loss', log['val_loss']) run.log('loss', log['loss']) callbacks.append(LogRunMetrics()) model.fit_generator( train_generator, steps_per_epoch=5, epochs=3, verbose=1, # steps_per_epoch=50, epochs=30, verbose=1, callbacks=callbacks, validation_data=val_generator, validation_steps=80, workers=4) # # Loss/epoch plots plt.plot(model.history.history['categorical_crossentropy'], label='train') plt.plot(model.history.history['val_categorical_crossentropy'], label='val') plt.legend() plt.xlabel('epoch') plt.ylabel('logloss') # log this plot to the aml workspace so we can see it in the azure portal if remote_execution: run.log_image('logloss', plot=plt)