Created
February 5, 2020 06:01
-
-
Save dashjim/bb0cec4fbab4093fd6a820ba76a5bc12 to your computer and use it in GitHub Desktop.
plot Keras/tensorflow training history
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
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