Add graphing script for loss CSV

This commit is contained in:
City
2023-07-31 00:54:07 +02:00
parent 19e60b67c7
commit 78bf8fe0bc
2 changed files with 22 additions and 1 deletions
+20
View File
@@ -0,0 +1,20 @@
import os
import matplotlib.pyplot as plt
files = [f"models/{x}" for x in os.listdir("models") if x.endswith(".csv")]
step = []
data = {}
for fp in files:
with open(fp) as f:
lines = f.readlines()
if not step:
step = [int(x.split(",")[0]) for x in lines]
name = fp.split("/")[1].split("_")[0]
data[name] = [float(x.split(",")[1]) for x in lines]
fig, ax = plt.subplots()
ax.grid()
for name, val in data.items():
ax.plot(step, val, label=name)
plt.legend(loc="upper right")
plt.savefig('loss.png', dpi=300, bbox_inches='tight')