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 41 42 43 44 45 46 47 48 49
|
%matplotlib inline import matplotlib.pyplot as plt import json import numpy as np
file = open('data.txt') data = file.readlines()
def pluck(lst, key): return [x.get(key) for x in lst]
d = [] for i in data : c = json.loads(i) d.append(c) print(type(data[0])) print(type(d[0]))
fig = plt.figure(figsize = (7,5)) ax1 = fig.add_subplot(1, 1, 1)
train_loss_line = plt.plot(pluck(d, 'epoch'),pluck(d, 'train_loss'),'r-', label = u'train_loss')
val_loss_line = plt.plot(pluck(d, 'epoch'),pluck(d, 'val_loss'), 'b-', label = u'val_loss') plt.legend() plt.xlabel(u'epoch') plt.ylabel(u'loss') plt.title('Compare loss for different epoch in training') plt.show()
fig = plt.figure(figsize = (7,5)) ax2 = fig.add_subplot(1, 1, 1) p2 = plt.plot(pluck(d, 'epoch'),pluck(d, 'val_acc1'),'r-', label = u'Top-1') p3 = plt.plot(pluck(d, 'epoch'),pluck(d, 'val_acc5'), 'b-', label = u'Top-5') plt.legend() plt.xlabel(u'epoch') plt.ylabel(u'accuracy') plt.title('Compare acc of Top-1 and Top-5') plt.show()
|