-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_loss.py
More file actions
27 lines (23 loc) · 839 Bytes
/
plot_loss.py
File metadata and controls
27 lines (23 loc) · 839 Bytes
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
import re
import matplotlib.pyplot as plt
# Open and read the text file
file_path = 'C:\\Users\\sande\\Documents\\3D_vision\\Project\\Final_results\\test_HFS_main\\exp\\scan106\\womask_hfs\\logs\\loss.txt' # Replace with the actual path to your file
with open(file_path, 'r') as file:
lines = file.readlines()
# Parse iterations and losses from each line
iterations = []
losses = []
for line in lines:
match = re.search(r'iter:(\d+) loss = ([\d.]+)', line)
if match:
iter_num = int(match.group(1))
loss_val = float(match.group(2))
iterations.append(iter_num)
losses.append(loss_val)
# Plotting
plt.plot(iterations, losses, marker='o', linestyle='-', color='b')
plt.title('Iterations vs Loss')
plt.xlabel('Iterations')
plt.ylabel('Loss')
plt.grid(True)
plt.show()