-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
49 lines (39 loc) · 1.29 KB
/
client.py
File metadata and controls
49 lines (39 loc) · 1.29 KB
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
#!/usr/bin/env python
import glob
import sys
sys.path.append('gen-py')
try:
sys.path.insert(0, glob.glob('../../thrift-0.19.0/lib/py/build/lib*')[0])
except:
pass
#from client_thrift import *
from coordinator_node_thrift import *
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
def main():
if len(sys.argv) < 3:
print("python3 client.py <ip> <port>")
return
ip = sys.argv[1]
port = sys.argv[2]
transport = TSocket.TSocket(ip, port)
transport = TTransport.TBufferedTransport(transport)
protocol = TBinaryProtocol.TBinaryProtocol(transport)
c = coordinator.Client(protocol)
transport.open()
if c.init_coordinator('compute_nodes.txt'):
# dir, rounds, epoch, h, k, eta
# rounds = 25, H = 20, epochs = 15, eta = 0.0001. Validation error = 0.3 ~ 0.4
# rounds = 15, H = 24, epochs = 50, eta = 0.0001. Validation error = 0.2 ~ 0.4
c.train('letters', 15, 50, 24, 26, 0.0001)
# c.train('letters', 1, 5, 24, 26, 0.0001)
else:
print('Failed to prepare coordinator node')
transport.close()
if __name__ == '__main__':
try:
main()
except Thrift.TException as tx:
print('%s' % tx.message)