forked from Puzer/stylegan-encoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_loss_curves.py
44 lines (33 loc) · 1.19 KB
/
get_loss_curves.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
import argparse
import re
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Pull the loss information out of saved output.')
parser.add_argument('file_to_parse', help='file containing saved output')
args = parser.parse_args()
counters = []
losses = []
for line in open(args.file_to_parse, encoding='utf-8'):
match1 = re.search('counter: (\d+)', line)
match2 = re.search("Last Loss: (\d+.\d+)", line)
if match1 and match2:
counter = int(match1.group(1))
loss = float(match2.group(1))
counters.append(counter)
losses.append(loss)
encoder_data = pd.DataFrame(
{
"iteration": counters,
"loss":losses
}
)
print(encoder_data.head(10))
print(encoder_data.count())
# encoder_data = encoder_data.head(100)
# print(encoder_data.count())
plt.figure()
sns.lineplot(x="iteration",y="loss",data=encoder_data)
plt.savefig("loss_curve.png")