-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.py
40 lines (32 loc) · 902 Bytes
/
plot.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
39
40
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import pickle
import json
def main():
config = json.load(open("config.json"))
f = open(config['history'], 'rb')
history = pickle.load(f)
# summarize history for accuracy
fig = plt.figure(1)
plt.plot(history['train']['acc'])
plt.plot(history['val']['acc'])
plt.title("Model accuracy")
plt.ylabel("accuracy")
plt.xlabel("epoch")
plt.legend(["train", "val"], loc="upper left")
plt.savefig("accuracy.jpg")
plt.close(1)
# summarize history for loss
fig = plt.figure(2)
plt.plot(history['train']['loss'])
plt.plot(history['val']['loss'])
plt.title("Model loss")
plt.ylabel("loss")
plt.xlabel("epoch")
plt.legend(["train", "val"], loc="upper left")
plt.savefig("loss.jpg")
plt.close(2)
f.close()
if __name__ == '__main__':
main()