-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathshow_result_of_mnist_experiment.py
51 lines (45 loc) · 1.65 KB
/
show_result_of_mnist_experiment.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
41
42
43
44
45
46
47
48
49
50
51
import numpy as np
import matplotlib.pyplot as plt
__author__ = 'garrett_local'
def parse_result(result):
x = []
y = []
for idx, acc in enumerate(result):
if acc != -1: # acc equal to -1, meaning singular matrix problem exist.
x.append(idx / 10.)
y.append(acc)
return x,y
if __name__ == '__main__':
try:
x_cross_entropy, y_cross_entropy = \
parse_result(np.load('./result/mnist/cross_entropy.npy'))
x_forward, y_forward = \
parse_result(np.load('./result/mnist/forward.npy'))
x_forward_t, y_forward_t = \
parse_result(np.load('./result/mnist/forward_t.npy'))
x_backward, y_backward = \
parse_result(np.load('./result/mnist/backward.npy'))
x_backward_t, y_backward_t = \
parse_result(np.load('./result/mnist/backward_t.npy'))
except IOError, e:
print e.message
print ('No experiment result found, first run bash script '
'run_experiment_mnist.')
handler_cross_entropy, = plt.plot(x_cross_entropy, y_cross_entropy, 'yx-')
handler_backward, = plt.plot(x_backward, y_backward, 'rx-')
handler_backward_t, = plt.plot(x_backward_t, y_backward_t, 'rx--')
handler_forward, = plt.plot(x_forward, y_forward, 'bx-')
handler_forward_t, = plt.plot(x_forward_t, y_forward_t, 'bx--')
plt.legend(
[handler_cross_entropy,
handler_backward,
handler_backward_t,
handler_forward,
handler_forward_t],
['Cross Entropy',
'Backward',
'Backward T',
'Forward',
'Forward T'],
loc='lower left')
plt.show()