-
Notifications
You must be signed in to change notification settings - Fork 86
/
plot_util.py
73 lines (57 loc) · 1.9 KB
/
plot_util.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import numpy as np
import matplotlib
matplotlib.use("Agg") # to enable plot on non X11 env
from matplotlib import pyplot as plt
def plot_track(means, stds, title):
"""
Track means and stds as described in http://jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf
"""
fig = plt.figure()
ax = fig.add_subplot(111)
# plot the activation history
layer_i = 1
assert len(means[0]) > 0
colors = ["b", "g", "y"]
assert len(colors) > len(means)
for ms, std, color in zip(means, stds, colors):
ms, std = np.array(ms), np.array(std)
ax.plot(ms, color+'o-', label = "Layer %d" %(layer_i))
ax.hold(True)
#upper and lower
ax.plot(ms+std, color+'*-')
ax.plot(ms-std, color+'*-')
layer_i += 1
ax.set_title(title)
ax.legend(loc='best', fancybox=True)
def plot_hist(rows, title):
"""
histogram plot as described in http://jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf
"""
fig = plt.figure()
ax = fig.add_subplot(111)
# plot the activation history
layer_i = 1
assert len(rows[0]) > 0
for x in rows:
ax.hist(x,
bins = 100,
label = "Layer %d" %(layer_i),
normed = True,
histtype = "step"
)
ax.hold(True)
layer_i += 1
ax.set_title(title)
ax.legend(loc='best', fancybox = True)
def plot_error_vs_epoch(train_errors, dev_errors, title):
assert len(train_errors) == len(dev_errors)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(train_errors, 'ro-', label = "Training error")
ax.hold(True)
ax.plot(dev_errors, 'bo-', label = "Dev error")
ax.set_title(title)
ax.legend(loc = 'best', fancybox = True)
ax.set_xlabel('Age')
ax.set_ylabel('Error')
ax.set_ylim([0,1])