-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_error_lines_default.py
executable file
·61 lines (55 loc) · 1.8 KB
/
plot_error_lines_default.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
#!/usr/bin/env python
"""
Plot an x,y line graph...
"""
import sys
import time
import argparse
import matplotlib.pyplot as plt
parser = argparse.ArgumentParser(description='Plot error lines given a log file.')
parser.add_argument('file', metavar='f', type=str, nargs='?',
help='a log file to process')
parser.add_argument('label', metavar='l', type=str, nargs='?',
help='the label lines of interest start with')
parser.add_argument('xcol', metavar='x', type=int, nargs='?', default=4,
help='the column number containing the xs')
parser.add_argument('ycol', metavar='y', type=int, nargs='?', default=5,
help='the column number containing the ys')
args = parser.parse_args()
def main():
xrecon = []
xcross = []
xentr = []
ys = []
for l in open(args.file):
l = l.strip()
if l.startswith(args.label):
toks = l.split()
print toks
if 'LRecon' in l:
xrecon.append(toks[args.ycol - 1])
elif 'LCross' in l:
xcross.append(toks[args.ycol - 1])
elif 'LEntr' in l:
xentr.append(toks[args.ycol - 1])
ys.append(int(toks[args.xcol - 1]))
xrecon = [float(x) for x in xrecon]
xcross = [float(x) for x in xcross]
xentr = [float(x) for x in xentr]
ys = sorted(list(set(ys)))
plt.subplot(311)
plt.title('Reconstruction loss')
plt.axis('off')
plt.plot(ys,xrecon)
plt.subplot(312)
# plt.title('Cross entropy loss')
# plt.axis('off')
plt.plot(ys,xcross,label='discriminator')
# plt.subplot(313)
# plt.title('Entropy loss')
plt.axis('off')
plt.plot(ys,xentr,label='generator')
plt.legend(loc="lower left")
plt.show()
if __name__ == '__main__':
main()