-
Notifications
You must be signed in to change notification settings - Fork 2
/
Viz_single.py
82 lines (66 loc) · 3.23 KB
/
Viz_single.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
74
75
76
77
78
79
80
81
82
# Copyright 2020 Antonio Macaluso
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# TODO refactor *viz* scripts with meaningful names and update the README
from Utils_Spline import *
create_dir('results/single/')
def plot_activation(x, y, qy, cy, x_fid, fid, label, approach):
# fig = plt.figure()
ax = plt.subplot()
ax.plot(x, y, color='orange', label='Classic spline', zorder=1)
ax.plot(x, qy, color='steelblue', label='QSpline')
ax.plot(x, cy, label='Activation', color='sienna', linestyle='dotted', dashes=(1, 1.5), zorder=2, linewidth=3)
ax.scatter(x_fid, fid, color='cornflowerblue', label='Fidelity', s=10)
ax.set_xlim(-1.1, 1.1)
# ax.set_ylim(-.2, 1.05)
ax.grid(alpha=0.3)
ax.set_xticks(np.round(np.arange(-1, 1.1, .4), 1).tolist())
ax.set_title(label, size=20)
ax.tick_params(labelsize=18)
plt.savefig('results/single/'+label+'_'+approach+'.png', dpi=300)
plt.show()
# ax.set_yticks(np.round(np.arange(-.2, 1.05, .2),1).tolist())
#ax.text(coord[0], coord[1], label, transform=ax.transAxes, ha="left")
approach='Hybrid'
x, y, qy, cy, x_fid, fid = load_data('sigmoid', approach)
plot_activation(x, y, qy, cy, x_fid, fid, 'Sigmoid', approach)
x, y, qy, cy, x_fid, fid = load_data('tanh', approach)
plot_activation(x, y, qy, cy, x_fid, fid, 'Tanh', approach)
x, y, qy, cy, x_fid, fid = load_data('relu', approach)
plot_activation(x, y, qy, cy, x_fid, fid, 'Relu', approach)
x, y, qy, cy, x_fid, fid = load_data('elu', approach)
plot_activation(x, y, qy, cy, x_fid, fid, 'Elu', approach)
approach='Full'
x, y, qy, cy, x_fid, fid = load_data('sigmoid', approach)
plot_activation(x, y, qy, cy, x_fid, fid, 'Sigmoid', approach)
x, y, qy, cy, x_fid, fid = load_data('tanh', approach)
plot_activation(x, y, qy, cy, x_fid, fid, 'Tanh', approach)
x, y, qy, cy, x_fid, fid = load_data('relu', approach)
plot_activation(x, y, qy, cy, x_fid, fid, 'Relu', approach)
x, y, qy, cy, x_fid, fid = load_data('elu', approach)
plot_activation(x, y, qy, cy, x_fid, fid, 'Elu', approach)
# Plot Legend
# ax = plt.subplot()
# ax.plot(x, y, color='orange', label='Classic spline', zorder=1)
# ax.plot(x, qy, color='steelblue', label='Full QSpline')
# ax.plot(x, cy, label='Activation', color='sienna', linestyle='dotted', dashes=(1, 1.5), zorder=2, linewidth=3)
# ax.scatter(x_fid, fid, color='cornflowerblue', label='Fidelity', s=10)
# ax.set_xlim(-1.1, 1.1)
# # ax.set_ylim(-.2, 1.05)
# ax.grid(alpha=0.3)
# ax.set_xticks(np.round(np.arange(-1, 1.1, .4), 1).tolist())
# #ax.set_title(label, size=20)
# ax.tick_params(labelsize=18)
#
# fig = plt.figure(figsize=(6, 1))
# handles, labels = ax.get_legend_handles_labels()
# fig.legend(handles, labels, loc='center', ncol=4)
# plt.savefig('results/legend_Full.png', dpi=300, bbox_inches='tight')
# plt.show()