Created
November 29, 2017 01:46
-
-
Save sethbunke/8d5d3f03777671034bda17a8322cec02 to your computer and use it in GitHub Desktop.
Keras show training and validation loss over time
This file contains hidden or 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.models import Model | |
import matplotlib.pyplot as plt | |
history_object = model.fit_generator(train_generator, samples_per_epoch = | |
len(train_samples), validation_data = | |
validation_generator, | |
nb_val_samples = len(validation_samples), | |
nb_epoch=5, verbose=1) | |
### print the keys contained in the history object | |
print(history_object.history.keys()) | |
### plot the training and validation loss for each epoch | |
plt.plot(history_object.history['loss']) | |
plt.plot(history_object.history['val_loss']) | |
plt.title('model mean squared error loss') | |
plt.ylabel('mean squared error loss') | |
plt.xlabel('epoch') | |
plt.legend(['training set', 'validation set'], loc='upper right') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment