-
Notifications
You must be signed in to change notification settings - Fork 10
/
memory_extract_stats_from_log.py
51 lines (43 loc) · 1.17 KB
/
memory_extract_stats_from_log.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
# by AnvaMiba
import sys
import cPickle
import numpy as np
def main():
if len(sys.argv) != 2:
usage()
outFs = open(sys.argv[1], 'wb')
i = 0
train_i_ce_acc_cacc = []
test_i_ce_acc_cacc = []
line = sys.stdin.readline()
while line:
tokens = line.split()
if (len(tokens)) > 0 and (tokens[0] == 'Iteration:'):
i = int(tokens[1])
line = sys.stdin.readline()
tokens = line.split()
if len(tokens) != 9:
break
ce = float(tokens[1])
acc = float(tokens[3])
cacc = float(tokens[6])
train_i_ce_acc_cacc.append([i, ce, acc, cacc])
if (len(tokens)) > 0 and (tokens[0] == 'TEST'):
line = sys.stdin.readline()
tokens = line.split()
if len(tokens) != 9:
break
ce = float(tokens[1])
acc = float(tokens[3])
cacc = float(tokens[6])
test_i_ce_acc_cacc.append([i, ce, acc, cacc])
line = sys.stdin.readline()
rv_dict = {'train_i_ce_acc_cacc': np.array(train_i_ce_acc_cacc), 'test_i_ce_acc_cacc': np.array(test_i_ce_acc_cacc)}
cPickle.dump(rv_dict, outFs, cPickle.HIGHEST_PROTOCOL)
outFs.close()
def usage():
print >> sys.stderr, 'Usage:'
print >> sys.stderr, sys.argv[0], 'pickle_out_file'
sys.exit(-1)
if __name__ == '__main__':
main()