verbose=0, mode='auto') ts = calendar.timegm(time.gmtime()) checkpointer = ModelCheckpoint(filepath=cnn_first_phase_folder + str(ts) + 'best_weights.hdf5', verbose=0, save_best_only=True) # save best model model.fit_generator(train_img_class_gen, steps_per_epoch=steps_per_small_epoch, epochs=small_epochs, verbose=2, validation_data=val_img_class_gen, validation_steps=val_steps_per_small_epoch, workers=4, callbacks=[monitor, checkpointer]) if i % saves_per_epoch == 0: print('{} epoch completed'.format(int(i / saves_per_epoch))) best_model.load_weights(cnn_first_phase_folder + str(ts) + 'best_weights.hdf5') best_model.save(cnn_first_phase_folder + str(ts) + 'best_models.h5') best_model.save(cnn_folder + 'cnn_first_phase.h5') if __name__ == '__main__': train_img_class_gen, val_img_class_gen = make_generators(isPlain=True) cnn(trained=False)
workers=4, callbacks=[tensorboard]) # history = new_inception_model.fit_generator(train_img_class_gen, # steps_per_epoch=steps_per_small_epoch, # epochs=small_epochs, verbose=2, # validation_data=val_img_class_gen, validation_steps=val_steps_per_small_epoch, # workers=4, callbacks=[LosswiseKerasCallback(tag='keras inception model')]) print("iteration", i) if i % saves_per_epoch == 0: print('{} epoch completed'.format(int(i / saves_per_epoch))) if i >= 5: ts = calendar.timegm(time.gmtime()) new_inception_model.save(third_phase_folder + str(ts) + '_inception_model.h5') save_obj(history.history, str(ts) + '_inception_history.h5', folder=third_phase_folder) new_inception_model.save(data_folder + '3rd_phase_inception_model.h5') if __name__ == '__main__': train_img_class_gen, val_img_class_gen = make_generators(isSimple=True) # iinception(trained=True) # first_phase(trained=False, printGap=False, first_phase_train_reps=10) # second_phase() third_phase(trained=False, third_phase_train_reps=10) # second_second_phase(trained=True) # continue_second(trained=True)