forked from hyunwoongko/transformer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.py
44 lines (33 loc) · 972 Bytes
/
graph.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
"""
@author : Hyunwoong
@when : 2019-12-18
@homepage : https://github.com/gusdnd852
"""
import matplotlib.pyplot as plt
import re
def read(name):
f = open(name, 'r')
file = f.read()
file = re.sub('\\[', '', file)
file = re.sub('\\]', '', file)
f.close()
return [float(i) for idx, i in enumerate(file.split(','))]
def draw(mode):
if mode == 'loss':
train = read('./result/train_loss.txt')
test = read('./result/test_loss.txt')
plt.plot(train, 'r', label='train')
plt.plot(test, 'b', label='validation')
plt.legend(loc='lower left')
elif mode == 'bleu':
bleu = read('./result/bleu.txt')
plt.plot(bleu, 'b', label='bleu score')
plt.legend(loc='lower right')
plt.xlabel('epoch')
plt.ylabel(mode)
plt.title('training result')
plt.grid(True, which='both', axis='both')
plt.show()
if __name__ == '__main__':
draw(mode='loss')
draw(mode='bleu')