Last active
December 12, 2019 03:56
-
-
Save miracleyoo/d053ce514a08bee694f16155563dc51d to your computer and use it in GitHub Desktop.
[plot loss acc] #python #pytorch #keras
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 os | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
def plot_history(history, save_path:str=None, figsize = (20, 9)): | |
f, axes = plt.subplots(1, 2, figsize=figsize) | |
sns.lineplot(range(1, history.epochs+1), history.history['acc'], label='Train Accuracy', ax=axes[0]) | |
sns.lineplot(range(1, history.epochs+1), history.history['val_acc'], label='Val Accuracy', ax=axes[0]) | |
sns.lineplot(range(1, history.epochs+1), history.history['loss'], label='Train Loss', ax=axes[1]) | |
sns.lineplot(range(1, history.epochs+1), history.history['val_loss'], label='Val Loss', ax=axes[1]) | |
plt.tight_layout() | |
if save_path is not None: | |
f.savefig(os.path.join(save_path+"history_output.png")) | |
else: | |
plt.show() | |
plot_history(history) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment