-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_final.py
147 lines (142 loc) · 8.4 KB
/
test_final.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#model_path
#dataset
#switch
#type
#bias1
#bias2
#lr
#max_steps
#3_3_notdown tmp
exp=[
['FB15k-model-rank-1000-epoch-100-1602520745.pt@',
'FB15k','True','1_1','0.0','0.0','0.1','0'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt/FB15k-ComplEx-model-rank-1000-epoch-100-lr-0.01-1645931834.pt',
'FB15k','True','1_2','0.0','0.99','0.001','1000000'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt/FB15k-ComplEx-model-rank-1000-epoch-100-lr-0.01-1645931834.pt',
'FB15k','True','1_3','0.0','0.0','0.1','0'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt@',
'FB15k','True','2_2','0.0','0.0','0.1','0'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt@',
'FB15k','True','2_3','0.0','0.0','0.1','0'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt/FB15k-ComplEx-model-rank-1000-epoch-100-lr-0.01-1645931834.pt',
'FB15k','True','4_3','0.0','0.0','0.0001','1000000'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt/FB15k-ComplEx-model-rank-1000-epoch-100-lr-0.01-1645931834.pt',
'FB15k','True','4_3','0.0','0.0','0.0001','1000000'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt/FB15k-ComplEx-model-rank-1000-epoch-100-lr-0.001-1645935098.pt',
'FB15k','True','3_3','0.0','0.0','0.0001','1000000'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt@',
'FB15k','True','2_2_disj','0.0','0.0','0.1','0'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt/FB15k-ComplEx-model-rank-1000-epoch-100-lr-0.01-1645931834.pt',
'FB15k','True','4_3_disj','0.0','0.92','0.001','1000000'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt@',
'FB15k','True','2_2_not','0.0','0.0','0.1','0'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt@',
'FB15k','True','2_3_not','0.0','0.0','0.1','0'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt/FB15k-ComplEx-model-rank-1000-epoch-100-lr-0.001-1645935098.pt',
'FB15k','True','4_3_not','0.0','0.0','0.0001','100000'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt/FB15k-ComplEx-model-rank-1000-epoch-100-lr-0.1-1645928605.pt',
'FB15k','True','3_3_notdown','0.0','0.0','0.001','100000'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt/FB15k-ComplEx-model-rank-1000-epoch-100-lr-0.01-1645931834.pt',
'FB15k','True','3_3_not','0.0','0.0','0.0001','100000'],
['FB15k-model-rank-1000-epoch-100-1602520745.pt/FB15k-ComplEx-model-rank-1000-epoch-100-lr-0.01-1645931834.pt',
'FB15k','True','3_3_not','0.0','0.2','0.0001','0'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt@',
'FB15k-237','True','1_1','0.0','0.0','0.1','0'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt/FB15k-237-ComplEx-model-rank-1000-epoch-100-lr-0.1-1645928282.pt',
'FB15k-237','True','1_2','0.0','0.99','0.0001','100000'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt/FB15k-237-ComplEx-model-rank-1000-epoch-100-lr-0.01-1645930071.pt',
'FB15k-237','True','1_3','0.0','0.00','0.001','100000'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt@',
'FB15k-237','True','2_2','0.0','0.0','0.1','0'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt@',
'FB15k-237','True','2_3','0.0','0.0','0.1','0'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt/FB15k-237-ComplEx-model-rank-1000-epoch-100-lr-0.001-1645931858.pt',
'FB15k-237','True','4_3','0.0','0.0','0.0001','1000000'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt/FB15k-237-ComplEx-model-rank-1000-epoch-100-lr-0.001-1645931858.pt',
'FB15k-237','True','3_3','0.0','0.0','0.0001','1000000'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt@',
'FB15k-237','True','2_2_disj','0.0','0.0','0.1','0'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt/FB15k-237-ComplEx-model-rank-1000-epoch-100-lr-0.1-1645928282.pt',
'FB15k-237','True','4_3_disj','0.0','0.92','0.0001','1000000'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt@',
'FB15k-237','True','2_2_not','0.0','0.0','0.1','0'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt@',
'FB15k-237','True','2_3_not','0.0','0.0','0.1','0'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt/FB15k-237-ComplEx-model-rank-1000-epoch-100-lr-0.1-1645928282.pt',
'FB15k-237','True','4_3_not','0.0','0.0','0.1','0'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt/FB15k-237-ComplEx-model-rank-1000-epoch-100-lr-0.01-1645930071.pt',
'FB15k-237','True','3_3_notdown','0.0','0.0','0.001','1000000'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt/FB15k-237-ComplEx-model-rank-1000-epoch-100-lr-0.01-1645930071.pt',
'FB15k-237','True','3_3_not','0.0','0.0','0.0001','1000000'],
['FB15k-237-model-rank-1000-epoch-100-1602508358.pt/FB15k-237-ComplEx-model-rank-1000-epoch-100-lr-0.001-1645931858.pt',
'FB15k-237','True','3_3_not','0.0','0.2','0.0001','0'],
['NELL-model-rank-1000-epoch-100-1602499096.pt@',
'NELL','True','1_1','0.0','0.0','0.1','0'],
['NELL-model-rank-1000-epoch-100-1602499096.pt/NELL-ComplEx-model-rank-1000-epoch-100-lr-0.1-1646013343.pt',
'NELL','True','1_2','0.0','0.0','0.0001','100000'],
['NELL-model-rank-1000-epoch-100-1602499096.pt/NELL-ComplEx-model-rank-1000-epoch-100-lr-0.1-1646013343.pt',
'NELL','True','1_2','0.0','0.99','0.0001','100000'],
['NELL-model-rank-1000-epoch-100-1602499096.pt/NELL-ComplEx-model-rank-1000-epoch-100-lr-0.1-1646013343.pt',
'NELL','True','1_3','0.0','0.0','0.0001','0'],
['NELL-model-rank-1000-epoch-100-1602499096.pt@',
'NELL','True','2_2','0.0','0.0','0.1','0'],
['NELL-model-rank-1000-epoch-100-1602499096.pt@',
'NELL','True','2_3','0.0','0.0','0.1','0'],
['NELL-model-rank-1000-epoch-100-1602499096.pt/NELL-ComplEx-model-rank-1000-epoch-100-lr-0.1-1646013343.pt',
'NELL','True','4_3','0.0','0.0','0.0001','100000'],
['NELL-model-rank-1000-epoch-100-1602499096.pt/NELL-ComplEx-model-rank-1000-epoch-100-lr-0.1-1646013343.pt',
'NELL','True','3_3','0.0','0.0','0.0001','100000'],
['NELL-model-rank-1000-epoch-100-1602499096.pt@',
'NELL','True','2_2_disj','0.0','0.0','0.1','0'],
['NELL-model-rank-1000-epoch-100-1602499096.pt/NELL-ComplEx-model-rank-1000-epoch-100-lr-0.1-1646013343.pt',
'NELL','True','4_3_disj','0.0','0.0','0.001','100000'],
['NELL-model-rank-1000-epoch-100-1602499096.pt/NELL-ComplEx-model-rank-1000-epoch-100-lr-0.1-1646013343.pt',
'NELL','True','4_3_disj','0.0','0.92','0.001','100000'],
['NELL-model-rank-1000-epoch-100-1602499096.pt@',
'NELL','True','2_2_not','0.0','0.0','0.1','0'],
['NELL-model-rank-1000-epoch-100-1602499096.pt@',
'NELL','True','2_3_not','0.0','0.0','0.1','0'],
['NELL-model-rank-1000-epoch-100-1602499096.pt/NELL-ComplEx-model-rank-1000-epoch-100-lr-0.1-1646013343.pt',
'NELL','True','4_3_not','0.0','0.0','0.1','0'],
['NELL-model-rank-1000-epoch-100-1602499096.pt/NELL-ComplEx-model-rank-1000-epoch-100-lr-0.01-1646014267.pt',
'NELL','True','3_3_notdown','0.0','0.0','0.1','0'],
['NELL-model-rank-1000-epoch-100-1602499096.pt/NELL-ComplEx-model-rank-1000-epoch-100-lr-0.001-1646015044.pt',
'NELL','True','3_3_not','0.0','0.0','0.1','0'],
['NELL-model-rank-1000-epoch-100-1602499096.pt/NELL-ComplEx-model-rank-1000-epoch-100-lr-0.1-1646013343.pt',
'NELL','True','3_3_not','0.0','0.3','0.1','0'],
]
import os
prefix='Our_benchmark'
os.makedirs(prefix,exist_ok=True)
os.system('cp test_final.py '+prefix+'/test_final.py')
os.system('cp kbc/models.py '+prefix+'/models.py')
output_file=prefix+'/benchmark.txt'
output=[]
cuda=0
with open(output_file,"w") as ff:
for item in exp:
ff.write(str(item))
ff.write('\n')
if item[0][-1]=='@':
model_path='models/converter/'+item[0][:-1]
matrix = 0
else:
model_path='models/converter/'+item[0]
matrix = 2
CMD="CUDA_VISIBLE_DEVICES="+str(cuda)+" python kbc/cqd_co.py "
args=["--model_path", model_path,
"--dataset", item[1], "--mode", "test", "--t_norm", 'prod',
"data/"+item[1],"--matrix",str(matrix),"--chain_type", item[3],
"--bias1",item[4],"--bias2",item[5],"--lr",item[6],"--prefix","/data/tmp","--max-steps",item[7]]
if item[2]=='True':
args.append('--switch')
if item[3]=='3_3_notdown':
args.append('--tmp')
for arg in args:
CMD=CMD+" "+arg
print(CMD)
os.system(CMD+" > "+prefix+'/tmp.txt')
with open(prefix+"/tmp.txt","r") as file:
line=file.readlines()[-1]
ff.write(line)
ff.write('\n')