forked from seaniezhao/torch_npss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.py
32 lines (22 loc) · 766 Bytes
/
temp.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
import re
import numpy as np
import matplotlib.pyplot as plt
file = open('harmonic0_0005.log', 'r')
text_content = file.read()
print(text_content)
#train = '(?<=average loss:)\s*\d*\.\d*'
pttern = re.compile(r'(?<=average loss: )\-*\s*\d*\.\d*')
train_loss = np.array(re.findall(pttern, text_content)).astype(np.float32)
t_pttern = re.compile(r'(?<=test loss: )\-*\s*\d*\.\d*')
test_loss = np.array(re.findall(t_pttern, text_content)).astype(np.float32)
test_loss[test_loss>1] /=100000
lst_iter = [i for i in range(1650)]
title = 'weight_decay_loss'
plt.plot(train_loss, '-b', label='train')
plt.plot(test_loss, '-r', label='test')
plt.xlabel("n epoch")
plt.title(title)
# save image
plt.savefig(title+".png") # should before show method
# show
plt.show()