-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bar_plots.py
216 lines (160 loc) · 6 KB
/
Bar_plots.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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import numpy as np
import matplotlib.pyplot as plt
import tikzplotlib as tkz
from matplotlib.backends.backend_pdf import PdfPages
import matplotlib as mpl
#plt.style.use("ggplot")
########### Comparison Strgglers ONLY ############################################
def parM_comparison():
N = 3
K=12
#fig, axs = plt.subplots(1, 3, figsize=(9, 3), sharey=True)
centralized = (.99, .97, .94)
Berrut8=(.872, .74, .776)#k=8
ParM8= (.6833, .6711, .2539)#k=8
Berrut10=(.872, .73, .774)#k=10
ParM10 = (.592, .59, .2043)#k=10
Berrut12=(.868, .72, .774)#k=12
ParM12 = (.5031, .5518, .1921)#k=12
width = 0.25
ind = np.arange(N)
names=('MNIST', 'Fashion-MNIST', 'CIFAR10')
plt.bar(ind, centralized, width, label='Base model (Best case)',zorder=3)
plt.bar(ind + width, Berrut8, width,
label='ApproxIFER',zorder=3)
plt.bar(ind + 2*width, ParM8, width,
label='ParM',zorder=3)
plt.ylabel('Accuracy', fontsize=18)
#plt.title('K='+str(K),x=.95, y=1.01)
plt.xticks(ind + width / 2, ('MNIST', 'Fashion-MNIST', 'CIFAR10'),fontsize=18)
#plt.legend(bbox_to_anchor=(0, 1.1), loc='upper left', ncol=3)
plt.legend(bbox_to_anchor=(1.07, 1.13), ncol=3, fontsize=12)
plt.grid(True,axis='y',zorder=0, color='grey')
plt.show()
#plt.savefig("ParM8.pdf")
######## Stragglers S=1,2,3
def extra_straggler():
N =3
K=8
Centralized=(.99, .97, .94)
BerrutS1 = (.868, .72, .774)
BerrutS2 = (.8256, .6554, .7405)
BerrutS3 = (.7747, .64, .7305)
ind = np.arange(N)
width = 0.15
plt.bar(ind, Centralized, width, label='Base model (Best case)',zorder=3)
plt.bar(ind+width, BerrutS1, width, label='S=1',zorder=3)
plt.bar(ind + 2*width, BerrutS2, width,
label='S=2',zorder=3)
plt.bar(ind + 3*width, BerrutS3, width,
label='S=3',zorder=3)
plt.ylabel('Accuracy',fontsize=18)
#plt.title('K='+str(K),x=.95, y=1.02)
plt.xticks(ind + width / 2, ('MNIST', 'Fashion-MNIST', 'CIFAR10'),fontsize=18)
#plt.legend(bbox_to_anchor=(0, 1.1), loc='upper left', ncol=4)
plt.legend(bbox_to_anchor=(1.11, 1.13), ncol=4, fontsize=12)
plt.grid(True,axis='y',zorder=0, color='grey')
plt.show()
# plt.savefig('destination_path.eps', format='eps')
############# Strglers COMPLEX models Comparison #############
#
def complex_straggler():
N = 5
K=10
centralized = (.94,.9334,.9365,.9407, .9285 )
# Berrut=()#k=8
# Berrut=()#k=12
Berrut=(.805, .812, .801,.817,.77 )#k=10
ind = np.arange(N)
width = 0.25
plt.bar(ind, centralized, width, label='Base model (Best case)',zorder=3)
plt.bar(ind + width, Berrut, width,
label='ApproxIFER ',zorder=3)
#plt.bar(ind + 2*width, ParM, width,label='ParM')
plt.ylabel('Accuracy',fontsize=18)
#plt.title('K='+str(K),x=.95, y=1.01)
plt.xticks(ind + width / 2, ('VGG16','ResNet34', 'ResNet50', 'DenseNet161', 'GoogLeNet'),fontsize=11.5)
plt.legend(bbox_to_anchor=(-.035, 1.13), loc='upper left', ncol=3,fontsize=14)
plt.grid(True, axis='y', zorder=0, color='grey')
plt.show()
######## ERRORS e=1,2,3
def error_123():
N =3
K=12
Centralized=(.99, .93, .94)
BerrutS1 = (.97, .79, .8981)
BerrutS2 = (.95, .805, .8966)
BerrutS3 = (.93, .82, .901)
ind = np.arange(N)
width = 0.15
plt.bar(ind, Centralized, width, label='Base model (Best case)',zorder=3)
plt.bar(ind+width, BerrutS1, width, label='E=1',zorder=3)
plt.bar(ind + 2*width, BerrutS2, width,
label='E=2',zorder=3)
plt.bar(ind + 3*width, BerrutS3, width,
label='E=3',zorder=3)
plt.ylabel('Accuracy',fontsize=18)
#plt.title('K='+str(K),x=.95, y=1.02)
plt.xticks(ind + 3*width / 2, ('MNIST', 'Fashion-MNIST', 'CIFAR10'),fontsize=18)
plt.legend(bbox_to_anchor=(-.07, 1.12), loc='upper left', ncol=4,fontsize=11)
plt.grid(True, axis='y', zorder=0, color='grey')
plt.show()
############ Error COMPLEX models Comparison #############
#
def error_complex():
beingsaved = plt.figure()
N = 5
K=12
centralized = (.94,.9334,.9365,.9407, .9285 )
# Berrut=()#k=8
# Berrut=()#k=12
Berrut=(.9, .8933, .8993,.9070,.8824 )#k=10
ind = np.arange(N)
width = 0.25
plt.bar(ind, centralized, width, label='Base model (Best case)',zorder=3)
plt.bar(ind + width, Berrut, width,
label='ApproxIFER ',zorder=3)
#plt.bar(ind + 2*width, ParM, width,label='ParM')
plt.ylabel('Accuracy', fontsize=18)
#plt.title('K='+str(K),x=.95, y=1.01)
plt.xticks(ind + width / 2, ('VGG16','ResNet34', 'ResNet50', 'DenseNet161', 'GoogLeNet'),fontsize=11.5)
plt.legend(bbox_to_anchor=(-0.035, 1.25), loc='upper left', ncol=1, fontsize=18)
plt.grid(True, axis='y', zorder=0, color='grey')
plt.show()
beingsaved.savefig('destination_path.eps', format='eps', dpi=1000)
#tkz.save("test.tex")
#plt.savefig("fig1.eps", format='eps')
def error_sig():
N = 2
#K=12
#fig, axs = plt.subplots(1, 3, figsize=(9, 3), sharey=True)
sig1 = (.9607, .8012)
sig10=(.9434, .7723)#k=8
sig100= (.9690, .8037)#k=8
Berrut10=(.872, .73, .774)#k=10
ParM10 = (.592, .59, .2043)#k=10
Berrut12=(.868, .72, .774)#k=12
ParM12 = (.5031, .5518, .1921)#k=12
width = 0.25
ind = np.arange(N)
names=('MNIST', 'Fashion-MNIST')
plt.bar(ind, sig1, width, label='$\sigma$=1',zorder=3)
plt.bar(ind + width, sig10, width,
label='$\sigma$=10',zorder=3)
plt.bar(ind + 2*width, sig100, width,
label='$\sigma$=100',zorder=3)
plt.ylabel('Accuracy', fontsize=18)
#plt.title('K='+str(K),x=.95, y=1.01)
plt.xticks(ind + width / 2, ('MNIST', 'Fashion-MNIST'),fontsize=18)
#plt.legend(bbox_to_anchor=(0, 1.1), loc='upper left', ncol=3)
plt.legend(bbox_to_anchor=(1.00, 1.16), ncol=3, fontsize=16)
plt.grid(True,axis='y',zorder=0, color='grey')
plt.show()
#plt.savefig("ParM8.pdf")
########################## MAIN
#parM_comparison()
#extra_straggler()
#complex_straggler()
#error_123()
#error_complex()
error_sig()