-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreproduce_results.py
82 lines (68 loc) · 2.32 KB
/
reproduce_results.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This scripts reproduce all results found in the article.
"""
import subprocess
import argparse
def callcmd(cmd):
pipes = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
stdout, stderr = pipes.communicate()
if __name__ == "__main__":
# Initialize argument parser
parser = argparse.ArgumentParser()
# Add arguments to parse for training
parser.add_argument("--run_commands",
type=int,
default=1,
help="If 1, runs the commands, else just print them"
)
# Parse the input for training parameters
args, unparsed = parser.parse_known_args()
# 1.0 Training dataset creation on n GPUS
print("##Creating training dataset")
cmd = "python Case_article.py --training=0 "
print(cmd,"\n")
if args.run_commands:
callcmd(cmd)
# 1.1 Perform the training for nmodel models
print("##Training of the models")
cmd= "python Case_article.py --training=1 --logdir=Case_article"
print(cmd,"\n")
if args.run_commands:
callcmd(cmd)
# 1.2 Create the 1D test dataset
print("##Creating the 1D test dataset")
cmd= "python Case_article_test1D.py --testing=0 "
print(cmd,"\n")
if args.run_commands:
callcmd(cmd)
# 1.3 Test on the 1D test dataset
print("##Testing in 1D (Figure 3)")
cmd = "python Case_article_test1D.py --testing=1"
cmd+= " --logdir=Case_article*/4_* --niter=1000"
print(cmd,"\n")
if args.run_commands:
callcmd(cmd)
# 1.4 Test in 2D
print("##Testing in 2D (Figure 4)")
cmd = "python Case_article_test2D.py --testing=1"
cmd+= " --logdir=Case_article*/4_* --niter=1000"
print(cmd,"\n")
if args.run_commands:
callcmd(cmd)
# 1.5 Test on real data
print("##Testing on real data (Figure 5 and 6)")
cmd = "cd realdata;"
cmd+= "python Process_realdata.py"
print(cmd,"\n")
if args.run_commands:
callcmd(cmd)
cmd = "python Case_article_test2D.py --plots=2"
cmd+= " --logdir=Case_article*/4_* --niter=1000"
print(cmd,"\n")
if args.run_commands:
callcmd(cmd)