Skip to content

Instantly share code, notes, and snippets.

@dashjim
Created February 5, 2020 06:01
Show Gist options
  • Save dashjim/bb0cec4fbab4093fd6a820ba76a5bc12 to your computer and use it in GitHub Desktop.
Save dashjim/bb0cec4fbab4093fd6a820ba76a5bc12 to your computer and use it in GitHub Desktop.
plot Keras/tensorflow training history
import matplotlib as mpl
import matplotlib.pyplot as plt
model = make_model()
model.load_weights(initial_weights)
model.layers[-1].bias.assign([0.0])
zero_bias_history = model.fit(
train_features,
train_labels,
batch_size=BATCH_SIZE,
epochs=20,
validation_data=(val_features, val_labels),
verbose=0)
def plot_loss(history, label, n):
# Use a log scale to show the wide range of values.
plt.semilogy(history.epoch, history.history['loss'],
color=colors[n], label='Train '+label)
plt.semilogy(history.epoch, history.history['val_loss'],
color=colors[n], label='Val '+label,
linestyle="--")
plt.xlabel('Epoch')
plt.ylabel('Loss')
plt.legend()
plot_loss(zero_bias_history, "Zero Bias", 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment