-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplot_hyper_results.py
58 lines (43 loc) · 1.36 KB
/
plot_hyper_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
import os
import sys
import gflags
import json
import glob
import numpy as np
import matplotlib.pyplot as plt
FLAGS = gflags.FLAGS
gflags.DEFINE_string('exp_dir', "./model", 'Folder '
' containing all the learning-rate experiments')
def main(argv):
# Utility main to load flags
try:
argv = FLAGS(argv) # parse flags
except gflags.FlagsError:
print ('Usage: %s ARGS\\n%s' % (sys.argv[0], FLAGS))
sys.exit(1)
evas = []
rmses = []
lrs = []
experiments = glob.glob(FLAGS.exp_dir + '/expr*')
for exp_name in experiments:
file_name = os.path.join(exp_name, 'test_results.json')
lr = file_name.split('/')[-2]
lr = float(lr.split('_')[-1])
lrs.append(lr)
with open(file_name, 'r') as f:
results_dict = json.load(f)
predicted_dict = results_dict['predicted']
evas.append(predicted_dict[0]['evas'][0])
rmses.append(predicted_dict[0]['rmse'])
evas = np.array(evas)
rmses = np.array(rmses)
lrs = np.array(lrs)
plt.subplot(2, 1, 1)
plt.stem(lrs, evas)
plt.title('EVA')
plt.subplot(2, 1, 2)
plt.stem(lrs, rmses)
plt.title('RMSE')
plt.savefig(os.path.join(FLAGS.exp_dir, 'evas_rmses.png'))
if __name__ == "__main__":
main(sys.argv)