-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrid_search_plot.py
More file actions
53 lines (43 loc) · 1.22 KB
/
Copy pathgrid_search_plot.py
File metadata and controls
53 lines (43 loc) · 1.22 KB
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
import pickle
import matplotlib.pyplot as plt
etas = [1e-2, 5e-3, 1e-3, 5e-4, 1e-4]
alphas = [1e-1, 5e-2, 1e-2, 5e-3]
optim_names = [(eta,alpha) for eta in etas for alpha in alphas]
color_eta = {
1e-2:'tab:red',
5e-3:'tab:blue',
1e-3:'tab:green',
5e-4:'tab:orange',
1e-4:'tab:pink'
}
style_alpha = {
5e-3: 'solid',
1e-2: 'dashed',
5e-2: 'dotted',
1e-1: 'dashdot'
}
# style_eta = {
# 0.1:'solid',
# 1e-3:'dotted',
# 1e-7:'dashed',
# 1e-10:'dashdot'
# }
# color_alpha = {
# 5e-3: 'tab:red',
# 1e-3: 'tab:green',
# 5e-4: 'tab:blue',
# 1e-4: 'tab:orange',
# 5e-5: 'tab:pink'
# }
with open('losses_from_grid_search2', 'rb') as file:
losses = pickle.load(file)
plot_lines={}
for eta in etas:
for alpha in alphas:
plot_lines[(eta,alpha)], = plt.semilogy([1,2,3,4,5,6], losses[(eta,alpha)], color=color_eta[eta], linestyle=style_alpha[alpha])
legend1 = plt.legend([plot_lines[(eta,5e-3)] for eta in etas], ['η='+str(eta) for eta in etas], loc=1)
plt.legend([plot_lines[(1e-2,alpha)] for alpha in alphas], ['α='+str(alpha) for alpha in alphas], loc=3)
plt.gca().add_artist(legend1)
plt.xlabel("Number of epochs")
plt.ylabel("Loss")
plt.savefig('grid_search_plot')