-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_fed_avg_poets.py
49 lines (44 loc) · 1.46 KB
/
run_fed_avg_poets.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
import subprocess
params = {
'dataset': 'poets', # is expected to be one value to construct default experiment name
'model': 'stacked_lstm', # is expected to be one value to construct default experiment name
'num_rounds': 100,
'eval_every': 99,
'eval_on_fraction': 0.05,
'clients_per_round': 10,
'model_data_dir': './data/poets-balanced',
'batch_size': 10,
'num_batches': 200,
'learning_rate': 0.8
}
def main():
command = 'python -m fedavg ' \
'-dataset %s ' \
'-model %s ' \
'--num-rounds %s ' \
'--eval-every %s ' \
'--eval-on-fraction %s ' \
'--clients-per-round %s ' \
'--model-data-dir %s ' \
'--batch-size %s ' \
'--num-batches %s ' \
'-lr %s'
parameters = (
params['dataset'],
params['model'],
params['num_rounds'],
params['eval_every'],
params['eval_on_fraction'],
params['clients_per_round'],
params['model_data_dir'],
params['batch_size'],
params['num_batches'],
params['learning_rate'])
command = command % parameters
print('Training started...')
with open('fed_avg_output.txt', 'w+') as out_file:
training = subprocess.Popen(command.split(" "), stdout=out_file)
training.wait()
print('Training finished...')
if __name__ == '__main__':
main()