-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecord.py
36 lines (30 loc) · 1.08 KB
/
record.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
import numpy as np
client = 5
experiments = 5
bs = 16
lr = 0.0003
wd = 0.0001
dataset = "domainnet"
algs = ["local", "fedavg", "fedsplit", "fedprox", "fedgen", "fedcg_w", "feddf"]
for alg in algs:
print(alg)
fdir = 'experiments/bs' + str(bs) + 'lr' + str(lr) + 'wd' + str(wd) + '/' + alg + '_' + dataset + str(
client) + '_lenet5_'
if alg == 'fedcg_w':
fdir += "mse_"
nums = [[] for _ in range(client)]
avg_nums = []
for i in range(1, experiments + 1):
fname = fdir + str(i) + '/log.txt'
with open(fname, 'r') as f:
lines = f.readlines()[-client:]
sum_num = 0
for j in range(client):
num = float(lines[j].split(" test acc:")[1][:8])
nums[j].append(num)
sum_num += num
avg_nums.append(sum_num / client)
for j in range(client):
print("client:%2d, acc:%.4f(%.4f)" % (j + 1, np.mean(np.array(nums[j])), np.std(np.array(nums[j]))))
print("total average")
print("%.4f(%.4f)" % (np.mean(np.array(avg_nums)), np.std(np.array(avg_nums))))