Permalink
Fetching contributors…
Cannot retrieve contributors at this time
47 lines (35 sloc) 1.07 KB
#
# Run: python3 -i mnist_model_create.py
#
import matplotlib.pyplot as plt
import mnist_model as m
def plot_loss(history):
loss = history.history['loss']
val_loss = history.history['val_loss']
epochs = range(1, len(loss) + 1)
plt.figure()
# "bo" is for "blue dot"
plt.plot(epochs, loss, 'bo', label='Training loss')
# b is for "solid blue line"
plt.plot(epochs, val_loss, 'b', label='Validation loss')
plt.title('Training and validation loss')
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.legend()
plt.show(block=False)
def plot_acc(history):
acc = history.history['acc']
val_acc = history.history['val_acc']
epochs = range(1, len(acc) + 1)
plt.figure()
plt.plot(epochs, acc, 'bo', label='Training acc')
plt.plot(epochs, val_acc, 'b', label='Validation acc')
plt.title('Training and validation accuracy')
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.legend()
plt.show(block=False)
model = m.MnistModel("../data/mnist_model.h5")
model.load(True)
plot_acc(model.history)
plot_loss(model.history)