Last active
October 15, 2020 20:36
-
-
Save esmitt/602f03553781dbb97317d66bbd7a7782 to your computer and use it in GitHub Desktop.
Plotting the loss function using a log scale using Matplotlib
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.pyplot as plt | |
from matplotlib import rcParams | |
rcParams['figure.figsize'] = (12, 10) | |
colors = plt.rcParams['axes.prop_cycle'].by_key()['color'] | |
def plot_log_loss(history: History, title_label: str, n: int) -> (): | |
# Use a log scale to show the wide range of values. | |
plt.semilogy(history.epoch, history.history['loss'], | |
color=colors[n], label='Train '+title_label) | |
plt.semilogy(history.epoch, history.history['val_loss'], | |
color=colors[n], label='Val '+title_label, | |
linestyle="--") | |
plt.xlabel('Epoch') | |
plt.ylabel('Loss') | |
plt.legend() | |
plot_log_loss(history, "Model Base", 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment