Skip to content

Commit bd8686d

Browse files
committed
update plot for mnist and femnist
1 parent 84cd318 commit bd8686d

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

plot_femnist.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,16 @@
1313
import torch
1414
torch.manual_seed(0)
1515

16+
algorithms_list = ["FEDL","FedAvg","FEDL", "FEDL","FedAvg","FEDL", "FEDL","FedAvg","FEDL"]
17+
rho = [0,0,0,0,0,0,0,0,0,0,0,0]
18+
lamb_value = [0, 0, 0, 0, 0, 0, 0, 0, 0]
19+
learning_rate = [0.003, 0.003, 0.015, 0.003, 0.003, 0.015, 0.003, 0.003, 0.015]
20+
hyper_learning_rate = [0.2, 0, 0.5, 0.2, 0, 0.5, 0.2, 0, 0.5]
21+
local_ep = [10, 10, 10, 20, 20, 20, 40, 40, 40]
22+
batch_size = [20, 20, 0, 20, 20, 0, 20, 20, 0]
23+
DATA_SET = "Femnist"
24+
number_users = 10
25+
26+
plot_summary_nist(num_users=number_users, loc_ep1=local_ep, Numb_Glob_Iters=800, lamb=lamb_value,
27+
learning_rate=learning_rate, hyper_learning_rate = hyper_learning_rate, algorithms_list=algorithms_list, batch_size=batch_size, rho = rho, dataset=DATA_SET)
28+
print("-- FINISH -- :",)

plot_mnist.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,14 @@
1313
import torch
1414
torch.manual_seed(0)
1515

16-
def main(dataset, algorithm, model, batch_size, learning_rate, hyper_learning_rate, L, num_glob_iters,
17-
local_epochs, optimizer, clients_per_round, times):
16+
algorithms_list = ["FEDL","FedAvg","FEDL","FedAvg","FEDL","FedAvg","FEDL","FEDL"]
17+
rho = [0,0,0,0,0,0,0,0,0,0,0,0,0]
18+
lamb_value = [0, 0, 0, 0, 0, 0,0, 0, 0, 0]
19+
learning_rate = [0.003,0.003,0.003,0.003,0.003,0.003,0.003,0.003]
20+
hyper_learning_rate = [0.2,0,0.2,0,0.2,0,2.0,4.0]
21+
local_ep = [20, 20, 20, 20, 20, 20, 20, 20]
22+
batch_size = [20,20,40,40,0,0,0,0]
23+
DATA_SET = "Mnist"
24+
number_users = 10
25+
plot_summary_mnist(num_users=number_users, loc_ep1=local_ep, Numb_Glob_Iters=800, lamb=lamb_value,learning_rate=learning_rate, hyper_learning_rate = hyper_learning_rate, algorithms_list=algorithms_list, batch_size=batch_size, rho = rho, dataset=DATA_SET)
26+
print("-- FINISH -- :",)

utils/plot_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def plot_summary_nist(num_users=100, loc_ep1=[], Numb_Glob_Iters=10, lamb=[], le
350350
ax1.plot(glob_acc[i, 1:], linestyle=linestyles[i],
351351
label=algs_lbl[i] + " : " + '$B = $' + stringbatch + ', $\eta = $' + str(hyper_learning_rate[i]) + ', $K_l = $' + str(loc_ep1[i]))
352352
ax1.set_ylim([min, max])
353-
ax1.legend(loc='lower right')
353+
ax1.legend(loc='lower right', prop={'size': 10})
354354

355355
for i in range(num_al):
356356
stringbatch = str(batch_size[i+num_al])
@@ -359,7 +359,7 @@ def plot_summary_nist(num_users=100, loc_ep1=[], Numb_Glob_Iters=10, lamb=[], le
359359
ax2.plot(glob_acc[i+num_al, 1:], linestyle=linestyles[i],
360360
label=algs_lbl[i + num_al] + " : " + '$B = $' + stringbatch + ', $\eta = $' + str(hyper_learning_rate[i+num_al*1]) + ', $K_l = $' + str(loc_ep1[i + num_al]))
361361
ax2.set_ylim([min, max])
362-
ax2.legend(loc='lower right')
362+
ax2.legend(loc='lower right', prop={'size': 10})
363363

364364
for i in range(num_al):
365365
stringbatch = str(batch_size[i+num_al*2])
@@ -368,7 +368,7 @@ def plot_summary_nist(num_users=100, loc_ep1=[], Numb_Glob_Iters=10, lamb=[], le
368368
ax3.plot(glob_acc[i+num_al*2, 1:], linestyle=linestyles[i],
369369
label=algs_lbl[i + num_al*2] + " : " + '$B = $' + stringbatch + ', $\eta = $' + str(hyper_learning_rate[i+num_al*2]) + ', $K_l = $' + str(loc_ep1[i+ 2*num_al]))
370370
ax3.set_ylim([min, max])
371-
ax3.legend(loc='lower right')
371+
ax3.legend(loc='lower right', prop={'size': 10})
372372

373373
ax.set_title('FEMNIST', y=1.02)
374374
ax.set_xlabel('Global rounds ' + '$K_g$')

0 commit comments

Comments
 (0)