-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
62 lines (42 loc) · 1.38 KB
/
main.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
import subprocess
import pandas as pd
import os
from random import randint
from datamaker import func
from poisonData import poisonData
port = 5002
final_results = pd.DataFrame(columns=['Client no.', 'Type', 'Epoch', 'Average Loss', 'Accuracy'])
file_path = 'final_results_2.csv'
csv_file = "spamdata_v2.csv"
poison_csv_file = "poison_data.csv"
if os.path.isfile(file_path):
print('The file exists')
else:
print('The file does not exist')
final_results.to_csv(file_path)
func()
poisonData()
client = 5 # number of times to run the file
epochs = 1
numberOfRounds = 10
filename = "client1.py" # name of the file to run
data = []
numberOfData = 1500
# change the number of samples
for _ in range(client):
data.append((str(numberOfData)))
top_select = 3
number_of_cluster = 1
processes = []
processes.append(subprocess.Popen(
["python3", "server2.py"] + [str(port), str(number_of_cluster), str(top_select), str(numberOfRounds)]))
# comment this to do not make poison client
# processes.append(subprocess.Popen(["python3", filename] + [str(port), str(-1), str(0 + 1), str(epochs), poison_csv_file]))
for i in range(client):
processes.append(subprocess.Popen(["python3", filename] + [str(port), data[i], str(i + 1), str(epochs), csv_file]))
for process in processes:
process.wait()
"""
16 cl 15 ep 5clu top`2 -> 2000 data
32 20 8 top 2 -> 1000 data
"""