Created
February 3, 2019 09:35
-
-
Save jainanchit51/7a4145185f322d10133ffccb12d4cf2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.callbacks import ModelCheckpoint | |
# Creating the tensorflow session to train the model and save checkpoint after every epoch. | |
with tf.Session() as session: | |
K.set_session(session) | |
session.run(tf.global_variables_initializer()) | |
session.run(tf.tables_initializer()) | |
filepath="drive/My Drive/Colab Notebooks/Northout/model-{epoch:02d}-{val_acc:.2f}.hdf5" | |
checkpoint = ModelCheckpoint(filepath, monitor='val_loss', verbose=0, save_best_only=False, save_weights_only=True, mode='auto', period=1) | |
callbacks_list = [checkpoint] | |
history = model.fit([train_q1, train_q2], | |
train_labels, | |
validation_data=([test_q1, test_q2], test_labels), | |
epochs=10, | |
batch_size=512, callbacks=callbacks_list) | |
# model.save('drive/My Drive/Colab Notebooks/Northout/final_model.h5') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment