forked from marco-rudolph/differnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog_to_csv.py
More file actions
34 lines (28 loc) · 1.15 KB
/
log_to_csv.py
File metadata and controls
34 lines (28 loc) · 1.15 KB
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
import csv
with open('./screw-16-log.log') as f:
lines = f.readlines()
with open('./result.csv', 'w') as f:
# create the csv writer
writer = csv.writer(f)
writer.writerow(["Epoch", "Train Loss", "Test Loss", "AUROC"])
test_loss = -100
train_loss = -100
auroc = -100
for line in lines:
parts = line.strip().split(" ")
if parts[0] == "Epoch:":
if parts[3] == "test_loss:":
epoch, test_loss = parts[1], parts[-1]
epoch = int(epoch) +1
# writer.writerow([epoch, "", test_loss])
else:
epoch, train_loss = parts[1], parts[-1]
## check if 1.0, 2.0 etc
if int(float(epoch)) == float(epoch) and float(epoch) != 0.0:
writer.writerow([epoch, train_loss, test_loss, auroc])
else:
writer.writerow([epoch, train_loss])
elif parts[0] == "AUROC:":
auroc = parts[3]
### Last epoch
writer.writerow([epoch, "", test_loss, auroc])