-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot.py
More file actions
180 lines (125 loc) · 5.08 KB
/
plot.py
File metadata and controls
180 lines (125 loc) · 5.08 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import numpy as np
import matplotlib.pyplot as plt
def plot_gaussian_ab():
# scale = 0.5
# lr = 1e-3
# epochs = 200
# scale = 1.0
# lr = 1e-4
# epochs = 150
scale = 2.0
lr = 2e-6
epochs = 201
ab_list = [(0.1, 0.1), (0.5, 1.5), (2., 2.)]
fig=plt.figure(figsize=(9,6))
plt.rcParams['font.family'] = ['Times New Roman']
plt.yticks(fontproperties = 'Times New Roman', size = 25)
plt.xticks(fontproperties = 'Times New Roman', size = 25)
for a,b in ab_list:
ab_path = f'./log/ar/dim5_T100_iso1/lsa_a{a}_b{b}_scale{scale}_clipFalse_lr{lr}_seed1/ab.npy'
ab = np.load(ab_path)
plt.plot(ab[:epochs],label=f"$(a_0,b_0)$ = ({a}, {b})", linewidth=2.5)
theory_item = (0.2 / scale ** 2)
theory = theory_item * np.ones(shape=(200))
plt.plot(theory[:epochs], '--',label=f"$1/5\sigma^2$ = {theory_item}", linewidth=2.5)
plt.ylabel('Dynamics of ab',labelpad=8, fontsize = 30)
plt.xlabel('Epoch',labelpad=8, fontsize = 30)
plt.legend(fontsize = 20)
plt.savefig(f'./figs/ab_gaussian_scale{scale}.jpg',bbox_inches='tight', dpi=400)
def plot_gaussian_gap():
# scale = 0.5
# lr = 1e-3
# epochs = 200
# scale = 1.0
# lr = 1e-4
# epochs = 150
scale = 2.0
lr = 2e-6
epochs = 201
ab_list = [(0.1, 0.1), (0.5, 1.5), (2., 2.)]
fig=plt.figure(figsize=(9,6))
plt.rcParams['font.family'] = ['Times New Roman']
plt.yticks(fontproperties = 'Times New Roman', size = 25)
plt.xticks(fontproperties = 'Times New Roman', size = 25)
for a,b in ab_list:
ab_path = f'./log/ar/dim5_T100_iso1/lsa_a{a}_b{b}_scale{scale}_clipFalse_lr{lr}_seed1/gap.npy'
ab = np.load(ab_path)
plt.plot(ab[1:epochs],label=f"$(a_0,b_0)$ = ({a}, {b})", linewidth=2.5)
theory_item = 0.2
theory = theory_item * np.ones(shape=(200))
plt.plot(theory[:epochs], '--',label=f"Ratio = {theory_item}", linewidth=2.5)
plt.ylabel('Ratio of pred/true at $T_{te}$',labelpad=8, fontsize = 30)
plt.xlabel('Epoch',labelpad=8, fontsize = 30)
plt.legend(fontsize = 20)
plt.savefig(f'./figs/gap_gaussian_scale{scale}.jpg',bbox_inches='tight', dpi=400)
plt.show()
def plot_sparse_ab():
# scale = 0.5
# lr = 3e-2
# epochs = 200
scale = 1.0
lr = 1e-3
epochs = 201
# scale = 2.0
# lr = 1e-4
# epochs = 121
ab_list = [(0.1, 0.1), (0.5, 1.5), (2., 2.)]
fig=plt.figure(figsize=(9,6))
plt.rcParams['font.family'] = ['Times New Roman']
plt.yticks(fontproperties = 'Times New Roman', size = 25)
plt.xticks(fontproperties = 'Times New Roman', size = 25)
for a,b in ab_list:
ab_path = f'./log/ar/dim5_T100_iso2/lsa_a{a}_b{b}_scale{scale}_clipFalse_lr{lr}_seed1/ab.npy'
ab = np.load(ab_path)
plt.plot(ab[1:epochs],label=f"$(a_0,b_0)$ = ({a}, {b})", linewidth=2.5)
theory_item = (1 / scale ** 2)
theory = theory_item * np.ones(shape=(200))
plt.plot(theory[:epochs], '--',label=f"$1/c^2$ = {theory_item}", linewidth=2.5)
plt.ylabel('Dynamics of ab',labelpad=8, fontsize = 30)
plt.xlabel('Epoch',labelpad=8, fontsize = 30)
plt.legend(fontsize = 20)
plt.savefig(f'./figs/ab_sparse_scale{scale}.jpg',bbox_inches='tight', dpi=400)
def plot_sparse_gap():
# scale = 0.5
# lr = 3e-2
# epochs = 200
scale = 1.0
lr = 1e-3
epochs = 201
# scale = 2.0
# lr = 1e-4
# epochs = 121
ab_list = [(0.1, 0.1), (0.5, 1.5), (2., 2.)]
fig=plt.figure(figsize=(9,6))
plt.rcParams['font.family'] = ['Times New Roman']
plt.yticks(fontproperties = 'Times New Roman', size = 25)
plt.xticks(fontproperties = 'Times New Roman', size = 25)
for a,b in ab_list:
ab_path = f'./log/ar/dim5_T100_iso2/lsa_a{a}_b{b}_scale{scale}_clipFalse_lr{lr}_seed1/gap.npy'
ab = np.load(ab_path)
plt.plot(ab[5:epochs],label=f"$(a_0,b_0)$ = ({a}, {b})", linewidth=2.5)
theory_item = 0
theory = theory_item * np.ones(shape=(200))
plt.plot(theory[:epochs], '--',label=f"Theoretical MSE = {theory_item}", linewidth=2.5)
plt.ylabel('MSE loss at $T_{te}$',labelpad=8, fontsize = 30)
plt.xlabel('Epoch',labelpad=8, fontsize = 30)
plt.legend(fontsize = 20)
plt.savefig(f'./figs/gap_sparse_scale{scale}.jpg',bbox_inches='tight', dpi=400)
plt.show()
def plot_full_one_W():
ab_list = [(0.1, 0.1), (0.5, 1.5), (2., 2.)]
for a,b in ab_list:
ab_path = f'./log/ar/dim5_T100_iso0/lsa_a{a}_b{b}_scale1.0_clipFalse_lr0.0005_seed1/WPV.npy'
ab = np.load(ab_path)
plt.imshow(ab, cmap='viridis', interpolation='nearest')
plt.colorbar()
plt.savefig(f'./figs/full_a{a}_b{b}_WPV.jpg',bbox_inches='tight', dpi=400)
plt.close()
ab_path = f'./log/ar/dim5_T100_iso0/lsa_a{a}_b{b}_scale1.0_clipFalse_lr0.0005_seed1/WKQ.npy'
ab = np.load(ab_path)
plt.imshow(ab, cmap='viridis', interpolation='nearest')
plt.colorbar()
plt.savefig(f'./figs/full_a{a}_b{b}_WKQ.jpg',bbox_inches='tight', dpi=400)
plt.close()
if __name__ == '__main__':
plot_full_one_W()