-
Notifications
You must be signed in to change notification settings - Fork 1
/
__main__.py
72 lines (56 loc) · 2.66 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
63
64
65
66
67
68
69
70
71
72
'''
Created on 2018/10/27
@author: Han Zhang
An example script to train graph embeddings using DNELA, save to file afterwards
'''
import graph
import distributed as ds
import argparse
def main():
'''
main method of the pre_experiment program
parameters:
'''
parser = argparse.ArgumentParser()
parser.add_argument('-d',help="whether to use default values",action="store_true")
parser.add_argument('-c',help="continued training path",action="store_true")
parser.add_argument('--embpath',help="the embedding path for continued training")
parser.add_argument('--path',help="path of the graph")
parser.add_argument('--output',help="output path of the embeddings")
parser.add_argument('--dimension',type=int,default=128, help="dimension of embeddings")
parser.add_argument('--updates',type=int,help="number of updates")
parser.add_argument('--alpha',type=float,default=0.025,help="initial learning rate")
parser.add_argument('--negative',type=int,default=5,help="negative sampling number")
parser.add_argument('--neglen',type=int,default=10**8,help="the maximum number used for negative sampling")
parser.add_argument('--ratio',type=float,help="the ratio of numbers of 1st and 2nd degree nodes")
parser.add_argument('--fmax',default=1, type=float,help=
"the maximum ratio of # of 1st deg nodes participating updates to the total # of 1st deg nodes, when ratio=0.5")
#parser.add_argument('-p',help="whether to use poisson process",action="store_true")
parser.add_argument('--window',type=int,help="the update window in poisson update mode")
parser.add_argument('--timeslot',default=1000,type=int,help="the number of timeslots in order to simulate poisson process")
parser.add_argument('--seed',default=1,type=int,help="the random seed of a Distributed instance")
args = parser.parse_args()
G = graph.load_matfile(file_=args.path)
d = ds.Distributed(G)
if args.d:
print('using default settings')
d.defaultArgs()
else:
d.setArgs(alpha=args.alpha,
numUpdates=args.updates,
numNegSampling=args.negative,
maxNeglen=10**8,
representSize=args.dimension,
outputPath=args.output,
ratio=args.ratio,
fmax=args.fmax,
c=args.c,
cpath=args.embpath,
poisson=True,
window=args.window,
timeslot=args.timeslot,
seed=args.seed)
d.process()
d.save2File()
if __name__ == '__main__':
main()