Skip to content

Instantly share code, notes, and snippets.

@Karts27

Karts27/plot.py Secret

Created August 31, 2021 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Karts27/de62a58e57d493d8a0ceb37e8939f317 to your computer and use it in GitHub Desktop.
Save Karts27/de62a58e57d493d8a0ceb37e8939f317 to your computer and use it in GitHub Desktop.
# Function to plot "accuracy vs epoch" graphs and "loss vs epoch" graphs for training and validation data
def plot_metrics(model_name, metric = 'accuracy'):
if metric == 'loss':
plt.title("Loss Values")
plt.plot(model_name.history['loss'], label = 'train')
plt.plot(model_name.history['val_loss'], label = 'test')
plt.legend()
plt.show()
else:
plt.title("Accuracy Values")
plt.plot(model_name.history['accuracy'], label='train')
plt.plot(model_name.history['val_accuracy'], label='test')
plt.legend()
plt.show()
plot_metrics(history, 'accuracy')
plot_metrics(history, 'loss')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment