Skip to content

Commit 14518c9

Browse files
committed
More results and Delete client models
1 parent 2be14e3 commit 14518c9

20 files changed

+108
-8
lines changed

orchestrator/orchestrator.py

+9
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ def main(op_mode, communication_rounds):
8585
logging.info('Iteration {}...'.format(i))
8686
send_iteration_to_frontend(i)
8787

88+
logging.info('Deleting client models...')
89+
url = 'http://{}:{}/del_client_models'.format(
90+
hosts['secure_aggregator']['host'],
91+
hosts['secure_aggregator']['port']
92+
)
93+
res = requests.post(url)
94+
check_response_ok(res)
95+
logging.info('Done')
96+
8897
logging.info('Sending /train_model request to clients...')
8998
ch.perform_requests_and_wait('train_model')
9099
#logging.info('Performed clients: {}'.format(performed_clients))

results/5_clients_1_frame/extract_results.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
12
def extract_results(fn):
23
data = {}
3-
last_epoch = -1
44
clustering = False
55
with open(fn, 'r') as f:
66
for l in f:
@@ -11,15 +11,19 @@ def extract_results(fn):
1111
epoch = int(s[0].split('[')[1].split(']')[0])
1212
top_1 = float(s[-2].split(' ')[1].split(' ')[0])
1313
top_3 = float(s[-1].split(' ')[1].split(' ')[0])
14+
time = float(s[1].split(' ')[1].split(' ')[0])
1415
if clustering:
1516
data.setdefault(epoch, {}).setdefault('test-top1-clustering', []).append(top_1)
1617
data[epoch].setdefault('test-top3-clustering', []).append(top_3)
1718
else:
1819
data.setdefault(epoch, {}).setdefault('test-top1', []).append(top_1)
1920
data[epoch].setdefault('test-top3', []).append(top_3)
20-
if last_epoch != epoch:
21-
print('Extracting epoch', epoch)
22-
last_epoch = epoch
21+
if l.startswith('Test') or l.startswith('Train'):
22+
s = l.split('\t')
23+
epoch = int(s[0].split('[')[1].split(']')[0])
24+
time = float(s[1].split(' ')[1].split(' ')[0])
25+
data.setdefault(epoch, {}).setdefault('time', 0.0)
26+
data[epoch]['time'] += time
2327
return data
2428

2529
def avg(_list):
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
results = {0: {'test-top1': 17.462779156327542, 'test-top3': 39.73325062034739}, 1: {'test-top1': 31.674937965260547, 'test-top3': 57.411083746898264}, 2: {'test-top1': 30.43424317617866, 'test-top3': 55.27364205955335}, 3: {'test-top1': 34.026054590570716, 'test-top3': 57.44485794044665}, 4: {'test-top1': 38.65177853598015, 'test-top3': 60.79955893300248}, 5: {'test-top1': 37.68196836228288, 'test-top3': 60.16060111662531}, 6: {'test-top1': 40.578301488833745, 'test-top3': 62.80328101736973}, 7: {'test-top1': 35.774745037220846, 'test-top3': 57.41315136476427}, 8: {'test-top1': 41.339950372208435, 'test-top3': 63.39261104218362}, 9: {'test-top1': 35.57692307692308, 'test-top3': 59.23697270471464}, 10: {'test-top1': 40.421836228287845, 'test-top3': 60.803004962779156}, 11: {'test-top1': 36.32754342431762, 'test-top3': 60.45147518610422}, 12: {'test-top1': 31.477116004962777, 'test-top3': 56.06010483870968}, 13: {'test-top1': 38.22994230769231, 'test-top3': 61.11042183622829}, 14: {'test-top1': 37.96526054590571, 'test-top3': 59.4044665012407}, 15: {'test-top1': 40.898125310173704, 'test-top3': 62.81637717121588}, 16: {'test-top1': 40.259856699751865, 'test-top3': 61.74937965260546}, 17: {'test-top1': 39.83802047146402, 'test-top3': 62.20774751861042}, 18: {'test-top1': 41.177970843672455, 'test-top3': 62.697821960297766}, 19: {'test-top1': 41.43300248138958, 'test-top3': 62.70402543424317}, 20: {'test-top1': 39.312103598014886, 'test-top3': 61.38888895781638}, 21: {'test-top1': 39.10876736972705, 'test-top3': 62.74193548387097}, 22: {'test-top1': 40.607940446650126, 'test-top3': 62.25737531017369}, 23: {'test-top1': 40.12062282878412, 'test-top3': 62.83498759305211}, 24: {'test-top1': 41.67149131513648, 'test-top3': 62.23325062034739}, 25: {'test-top1': 40.607940446650126, 'test-top3': 63.49875930521092}, 26: {'test-top1': 42.42831513647643, 'test-top3': 63.455334987593055}, 27: {'test-top1': 38.50565198511166, 'test-top3': 60.7678523573201}, 28: {'test-top1': 41.30893300248139, 'test-top3': 62.03473945409429}, 29: {'test-top1': 39.88144478908189, 'test-top3': 61.178660049627794}, 30: {'test-top1': 40.17162965260546, 'test-top3': 61.22139516129032}, 31: {'test-top1': 39.565067617866006, 'test-top3': 61.525365384615384}, 32: {'test-top1': 40.42252543424318, 'test-top3': 61.364764267990076}, 33: {'test-top1': 41.79900744416874, 'test-top3': 62.03405024813895}, 34: {'test-top1': 40.53349875930521, 'test-top3': 62.86531575682382}, 35: {'test-top1': 40.71960297766749, 'test-top3': 61.31237965260546}, 36: {'test-top1': 40.931210297766754, 'test-top3': 62.54273511166253}, 37: {'test-top1': 39.88833746898263, 'test-top3': 62.03473945409429}, 38: {'test-top1': 39.844913151364764, 'test-top3': 62.52757071960298}, 39: {'test-top1': 39.62434491315137, 'test-top3': 61.74937965260546}, 40: {'test-top1': 40.58450496277916, 'test-top3': 61.38888895781638}, 41: {'test-top1': 41.53363647642679, 'test-top3': 62.10228846153846}, 42: {'test-top1': 43.15481141439206, 'test-top3': 63.31816935483871}, 43: {'test-top1': 41.36752109181142, 'test-top3': 63.03280955334987}, 44: {'test-top1': 39.59057071960298, 'test-top3': 61.12834305210918}, 45: {'test-top1': 42.69024007444169, 'test-top3': 64.26178660049628}, 46: {'test-top1': 39.6712158808933, 'test-top3': 61.59980707196029}, 47: {'test-top1': 41.07044416873449, 'test-top3': 61.934794665012404}, 48: {'test-top1': 41.068375930521086, 'test-top3': 63.03901302729528}, 49: {'test-top1': 41.15177853598015, 'test-top3': 63.026606079404466}, 50: {'test-top1': 41.15177853598015, 'test-top3': 63.026606079404466, 'test-top1-clustering': 41.15177853598015, 'test-top3-clustering': 63.026606079404466}}
1+
results = {0: {'time': 54.089000000001406, 'test-top1': 17.462779156327542, 'test-top3': 39.73325062034739}, 1: {'time': 54.33400000000157, 'test-top1': 31.674937965260547, 'test-top3': 57.411083746898264}, 2: {'time': 54.29600000000146, 'test-top1': 30.43424317617866, 'test-top3': 55.27364205955335}, 3: {'time': 54.38400000000163, 'test-top1': 34.026054590570716, 'test-top3': 57.44485794044665}, 4: {'time': 54.39200000000173, 'test-top1': 38.65177853598015, 'test-top3': 60.79955893300248}, 5: {'time': 54.254000000001525, 'test-top1': 37.68196836228288, 'test-top3': 60.16060111662531}, 6: {'time': 54.44000000000157, 'test-top1': 40.578301488833745, 'test-top3': 62.80328101736973}, 7: {'time': 54.431000000001596, 'test-top1': 35.774745037220846, 'test-top3': 57.41315136476427}, 8: {'time': 54.38100000000166, 'test-top1': 41.339950372208435, 'test-top3': 63.39261104218362}, 9: {'time': 54.331000000001545, 'test-top1': 35.57692307692308, 'test-top3': 59.23697270471464}, 10: {'time': 54.33600000000168, 'test-top1': 40.421836228287845, 'test-top3': 60.803004962779156}, 11: {'time': 54.37300000000157, 'test-top1': 36.32754342431762, 'test-top3': 60.45147518610422}, 12: {'time': 54.43800000000148, 'test-top1': 31.477116004962777, 'test-top3': 56.06010483870968}, 13: {'time': 54.05300000000153, 'test-top1': 38.22994230769231, 'test-top3': 61.11042183622829}, 14: {'time': 54.35700000000159, 'test-top1': 37.96526054590571, 'test-top3': 59.4044665012407}, 15: {'time': 54.379000000001604, 'test-top1': 40.898125310173704, 'test-top3': 62.81637717121588}, 16: {'time': 54.43200000000163, 'test-top1': 40.259856699751865, 'test-top3': 61.74937965260546}, 17: {'time': 54.33900000000156, 'test-top1': 39.83802047146402, 'test-top3': 62.20774751861042}, 18: {'time': 54.48800000000155, 'test-top1': 41.177970843672455, 'test-top3': 62.697821960297766}, 19: {'time': 54.28000000000167, 'test-top1': 41.43300248138958, 'test-top3': 62.70402543424317}, 20: {'time': 54.24200000000154, 'test-top1': 39.312103598014886, 'test-top3': 61.38888895781638}, 21: {'time': 54.25100000000166, 'test-top1': 39.10876736972705, 'test-top3': 62.74193548387097}, 22: {'time': 54.401000000001616, 'test-top1': 40.607940446650126, 'test-top3': 62.25737531017369}, 23: {'time': 54.32900000000156, 'test-top1': 40.12062282878412, 'test-top3': 62.83498759305211}, 24: {'time': 54.36400000000154, 'test-top1': 41.67149131513648, 'test-top3': 62.23325062034739}, 25: {'time': 54.43000000000164, 'test-top1': 40.607940446650126, 'test-top3': 63.49875930521092}, 26: {'time': 54.412000000001576, 'test-top1': 42.42831513647643, 'test-top3': 63.455334987593055}, 27: {'time': 54.432000000001636, 'test-top1': 38.50565198511166, 'test-top3': 60.7678523573201}, 28: {'time': 54.5070000000016, 'test-top1': 41.30893300248139, 'test-top3': 62.03473945409429}, 29: {'time': 54.518000000001535, 'test-top1': 39.88144478908189, 'test-top3': 61.178660049627794}, 30: {'time': 54.432000000001665, 'test-top1': 40.17162965260546, 'test-top3': 61.22139516129032}, 31: {'time': 54.214000000001555, 'test-top1': 39.565067617866006, 'test-top3': 61.525365384615384}, 32: {'time': 54.36600000000168, 'test-top1': 40.42252543424318, 'test-top3': 61.364764267990076}, 33: {'time': 54.35100000000157, 'test-top1': 41.79900744416874, 'test-top3': 62.03405024813895}, 34: {'time': 54.45900000000149, 'test-top1': 40.53349875930521, 'test-top3': 62.86531575682382}, 35: {'time': 54.38100000000156, 'test-top1': 40.71960297766749, 'test-top3': 61.31237965260546}, 36: {'time': 54.23700000000167, 'test-top1': 40.931210297766754, 'test-top3': 62.54273511166253}, 37: {'time': 54.102000000001546, 'test-top1': 39.88833746898263, 'test-top3': 62.03473945409429}, 38: {'time': 54.35300000000153, 'test-top1': 39.844913151364764, 'test-top3': 62.52757071960298}, 39: {'time': 54.33900000000159, 'test-top1': 39.62434491315137, 'test-top3': 61.74937965260546}, 40: {'time': 54.44600000000157, 'test-top1': 40.58450496277916, 'test-top3': 61.38888895781638}, 41: {'time': 54.43500000000168, 'test-top1': 41.53363647642679, 'test-top3': 62.10228846153846}, 42: {'time': 54.28200000000162, 'test-top1': 43.15481141439206, 'test-top3': 63.31816935483871}, 43: {'time': 53.94600000000138, 'test-top1': 41.36752109181142, 'test-top3': 63.03280955334987}, 44: {'time': 54.36000000000159, 'test-top1': 39.59057071960298, 'test-top3': 61.12834305210918}, 45: {'time': 54.36200000000148, 'test-top1': 42.69024007444169, 'test-top3': 64.26178660049628}, 46: {'time': 54.305000000001634, 'test-top1': 39.6712158808933, 'test-top3': 61.59980707196029}, 47: {'time': 54.27000000000154, 'test-top1': 41.07044416873449, 'test-top3': 61.934794665012404}, 48: {'time': 54.300000000001454, 'test-top1': 41.068375930521086, 'test-top3': 63.03901302729528}, 49: {'time': 54.197000000001516, 'test-top1': 41.15177853598015, 'test-top3': 63.026606079404466}, 50: {'test-top1': 41.15177853598015, 'test-top3': 63.026606079404466, 'time': 9.674000000000255, 'test-top1-clustering': 41.15177853598015, 'test-top3-clustering': 63.026606079404466}}

results/5_clients_1_frame/result.png

12.5 KB
Loading
330 KB
Loading

results/5_clients_1_frame/run.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
y_values = list(sorted(y_values, key=lambda t: t[0])) # Order by epoch asc
2727
y_values = [x[1] for x in y_values]
2828
plt.plot(X_AXIS, y_values, linewidth=1, label=legend[t], marker='o', markersize=MARKER_SIZE)
29-
plt.legend(loc="lower right")
29+
plt.legend(loc="upper right")
3030

3131
# IID results:
3232
from raw_5_clients_iid_1_frame import results
@@ -44,7 +44,7 @@
4444
linestyle='solid',
4545
marker="^",
4646
markersize=MARKER_SIZE)
47-
plt.legend(loc="lower right")
47+
plt.legend(loc="upper right")
4848

4949
# NON-IID results:
5050
from raw_5_clients_non_iid_1_frame import results
@@ -62,7 +62,7 @@
6262
linestyle='solid',
6363
marker="s",
6464
markersize=MARKER_SIZE)
65-
plt.legend(loc="lower right")
65+
plt.legend(loc="upper right")
6666

6767
# Limits
6868
plt.axis(xmin=0, xmax=epochs+1, ymin=0, ymax=100)
+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import matplotlib
2+
matplotlib.use('agg')
3+
import matplotlib.pyplot as plt
4+
5+
6+
MARKER_SIZE=2
7+
8+
# Init
9+
plt.figure()
10+
11+
#epochs = 50
12+
## Add vertical Lines
13+
#for i in range(epochs):
14+
# plt.axvline(
15+
# i+1, linewidth=0.5, color='black', linestyle='dotted', alpha=0.5)
16+
17+
# No FL results
18+
from raw_non_fedlearn_1_frame import results
19+
20+
timings = [(e, x['time']) for e, x in results.items()][:-1]
21+
timings = list(sorted(timings, key=lambda t: t[0])) # Order by epoch asc
22+
timings = [x[1] for x in timings]
23+
last = 0
24+
for i in range(len(timings)):
25+
timings[i] += last
26+
last = timings[i]
27+
28+
types = ['test-top1', 'test-top3']
29+
legend = {'test-top1': 'no-fl-top-1', 'test-top3': 'no-fl-top-3'}
30+
for t in types:
31+
y_values = [(e, x[t]) for e, x in results.items()][:-1]
32+
y_values = list(sorted(y_values, key=lambda t: t[0])) # Order by epoch asc
33+
y_values = [x[1] for x in y_values]
34+
plt.plot(timings, y_values, linewidth=1, label=legend[t], marker='o', markersize=MARKER_SIZE)
35+
plt.legend(loc="upper right")
36+
37+
# IID results:
38+
from raw_5_clients_iid_1_frame import results
39+
types = ['test-top1', 'test-top3']
40+
legend = {'test-top1': '5-clients-iid-top-1',
41+
'test-top3': '5-clients-iid-top-3'}
42+
timings = [x['elapsed_time'] for x in results]
43+
for t in types:
44+
y_values = [x['test_result'][t] for x in results]
45+
plt.plot(timings,
46+
y_values,
47+
linewidth=1,
48+
label=legend[t],
49+
linestyle='solid',
50+
marker="^",
51+
markersize=MARKER_SIZE)
52+
plt.legend(loc="upper right")
53+
54+
# NON-IID results:
55+
from raw_5_clients_non_iid_1_frame import results
56+
types = ['test-top1', 'test-top3']
57+
legend = {'test-top1': '5-clients-non-iid-top-1',
58+
'test-top3': '5-clients-non-iid-top-3'}
59+
timings = [x['elapsed_time'] for x in results]
60+
for t in types:
61+
y_values = [x['test_result'][t] for x in results]
62+
plt.plot(timings,
63+
y_values,
64+
linewidth=1,
65+
label=legend[t],
66+
linestyle='solid',
67+
marker="s",
68+
markersize=MARKER_SIZE)
69+
plt.legend(loc="upper right")
70+
71+
# Limits
72+
plt.axis(ymin=0, ymax=100)
73+
74+
# Labels
75+
plt.title('1 input frame comparison')
76+
plt.ylabel('Accuracy')
77+
plt.xlabel('Time (seconds)')
78+
79+
# Save
80+
plt.savefig('result_xtime.png', dpi=400)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

secure_aggregator/app.py

+7
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ def get_pub_key():
6363
return jsonify({'pub_key': rsa.export_public_key()})
6464

6565

66+
@assert_idle_state
67+
@app.route('/del_client_models', methods=['POST'])
68+
def del_client_models():
69+
sec_agg.delete_client_models()
70+
return jsonify({'ok': 1})
71+
72+
6673
@assert_idle_state
6774
@app.route('/client_model', methods=['POST'])
6875
def get_client_model():

0 commit comments

Comments
 (0)