-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualize.py
38 lines (30 loc) · 1.04 KB
/
visualize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# %% parse arguments
from argparse import ArgumentParser
from os import path
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
parser = ArgumentParser()
parser.add_argument('-m', '--model', required=True, help='Model Name')
args = vars(parser.parse_args())
modelDataPath = path.join('models', args['model'], 'data.csv')
if not path.exists(modelDataPath):
print(
f'[ERROR] the model "{args["model"]} has not been trained yet.',
f'Please train the model first and re-run this file.',
)
exit(1)
# %% run
modelData = pd.read_csv(modelDataPath, index_col=0)
epochs = np.arange(0, len(modelData))
plt.style.use('ggplot')
plt.title(f'Training Loss/Accuracy for {args["model"]} model')
plt.xlabel('# Epochs')
plt.ylabel('Loss/Accuracy')
plt.ylim(0, 1)
plt.plot(epochs, modelData.loss, label='loss')
plt.plot(epochs, modelData.accuracy, label='accuracy')
plt.plot(epochs, modelData.val_loss, label='val_loss')
plt.plot(epochs, modelData.val_accuracy, label='val_accuracy')
plt.legend(loc='center right')
plt.show()