-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_loss.py
More file actions
29 lines (21 loc) · 728 Bytes
/
Copy pathplot_loss.py
File metadata and controls
29 lines (21 loc) · 728 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
28
29
import json
import argparse
import matplotlib.pyplot as plt
def main():
parser = argparse.ArgumentParser()
parser.add_argument("json_path", help="Path to JSON file containing loss list")
parser.add_argument("--output", default="training_loss.png", help="Output image filename")
args = parser.parse_args()
with open(args.json_path, "r") as f:
losses = json.load(f)
iterations = list(range(1, len(losses) + 1))
plt.plot(iterations, losses)
plt.xlabel("Iterations")
plt.ylabel("Training Loss")
plt.title("Training Loss vs Iterations Dim 200")
plt.grid(True)
plt.tight_layout()
plt.savefig(args.output, dpi=300)
plt.show()
if __name__ == "__main__":
main()