Created
September 15, 2018 13:50
-
-
Save sdcubber/766763328d97f98f7c5a1d117d8389c6 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
# Saving a model | |
network.save(filepath='./network.h5') # architecture + weights | |
network_json = network.to_json() # only the architecture | |
network.save_weights() # only the weights | |
# Restoring a saved model | |
new_network = keras.models.load_model('./another_model.h5') | |
# Using the ModelCheckpoint callback during training | |
callbacks = [ | |
callbacks.ModelCheckpoint('./model.h5', verbose=1, save_best_only=True), | |
callbacks.EarlyStopping(monitor='val_loss', patience=2, verbose=1) | |
] | |
new_network.fit(train_images, | |
train_labels, | |
epochs=500, | |
batch_size=128, | |
validation_data=(val_images, val_labels), | |
callbacks=callbacks) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment