-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathparse_generalization_logs.py
More file actions
40 lines (33 loc) · 1.53 KB
/
parse_generalization_logs.py
File metadata and controls
40 lines (33 loc) · 1.53 KB
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
import re
import glob
import itertools
NUM_EXP = 3
NUM_REPEATS = 10
NUM_GENERALIZATION_POINTS = 2
target_res = [[] for _ in range(NUM_GENERALIZATION_POINTS)]
multi_res = [[] for _ in range(NUM_GENERALIZATION_POINTS)]
num_re = '([-+]?\d*\.\d+|\d+)'
log_dir = 'logs_ntm_diff_init_repeat_copy_10_runs_cosine_sim'
for log_file in sorted(glob.glob('{0}/*.txt'.format(log_dir))):
f = open(log_file, 'r').read()
try:
generalization_from_target_task = re.search('generalization_from_target_task: {0}'.format(','.join([num_re for _ in range(NUM_GENERALIZATION_POINTS)])), f).groups()
generalization_from_multi_task = re.search('generalization_from_multi_task: {0}'.format(','.join([num_re for _ in range(NUM_GENERALIZATION_POINTS)])), f).groups()
except AttributeError:
generalization_from_target_task = generalization_from_multi_task = ['None' for _ in range(NUM_GENERALIZATION_POINTS)]
for i in range(NUM_GENERALIZATION_POINTS):
target_res[i].append(generalization_from_target_task[i])
multi_res[i].append(generalization_from_multi_task[i])
print '\n'.join(sorted(glob.glob('{0}/*.txt'.format(log_dir))))
for i in range(NUM_GENERALIZATION_POINTS):
print '-' * 50
for j in range(NUM_EXP):
print '\n'.join(target_res[i][j*NUM_REPEATS:(j+1)*NUM_REPEATS])
print '\n'
print '-' * 50
for i in range(NUM_GENERALIZATION_POINTS):
print '-' * 50
for j in range(NUM_EXP):
print '\n'.join(multi_res[i][j*NUM_REPEATS:(j+1)*NUM_REPEATS])
print '\n'
print '-' * 50