forked from zshihang/MemN2N
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_benchmarks.py
77 lines (59 loc) · 1.98 KB
/
create_benchmarks.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
# File for creating benchmarks for all tasks in one go
import os
import subprocess
"""
TODO LIST:
1. Call cli.py with one command string
2. Make multiple calls and save output (dunno how I'm gonna do that)
#. Add joint architectures in
"""
NUM_TASKS = 20
BoW_3HOPS = {
"name": "BoW_3HOPS",
"is_joint": False,
"extra_options": ["--use_bow"]
}
PE_3HOPS = {
"name": "PE_3HOPS",
"is_joint": False,
"extra_options": []
}
ARCHS = [BoW_3HOPS, PE_3HOPS] # Note: Not currently having PE_3HOPS_JOINT or PE_LS_3HOPS_JOINT
results = {}
for arch in ARCHS:
dir_str = arch["name"]
results[arch["name"]] = []
command_calls = []
if arch["is_joint"]:
for i in range(NUM_TASKS):
task_num = i + 1
file_str = dir_str + "/task" + str(task_num)
command_str = "python3 cli.py --file " + file_str + " --task " + str(task_num) + " "
for opt in arch["extra_options"]:
command_str += opt + " "
command_calls.append(command_str)
else:
for i in range(NUM_TASKS):
task_num = i + 1
file_str = dir_str + "/task" + str(task_num)
command_str = "python3 cli.py --file " + file_str + " --task " + str(task_num) + " "
for opt in arch["extra_options"]:
command_str += opt + " "
command_calls.append(command_str)
task_counter = 1
for call in command_calls:
result = {}
print("Command Call:", call)
try:
result_str = str(subprocess.check_output([call], shell=True))
splits = result_str.split('\\n')
avg_error = splits[-2].split(" ")[-1]
print("Avg_error:", avg_error)
except:
print("Task", task_counter, "caused an error")
avg_error = -1
result["task_num"] = task_counter
result["avg_error"] = avg_error
task_counter += 1
results[arch["name"]].append(result)
print(results)