Skip to content

Create train_log_show.py #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions train_log_show.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import json
import matplotlib.pyplot as plt

# 从文件读取日志数据
with open("../trainer_log.jsonl", "r") as f:
logs = [json.loads(line) for line in f.readlines()]

# 提取关键信息
steps = [log["current_steps"] for log in logs]
loss = [log["loss"] for log in logs]
learning_rate = [log["learning_rate"] for log in logs]

# 创建一个新的图形
plt.figure()

# 画出损失曲线
plt.subplot(211)
plt.plot(steps, loss, label='Loss')
plt.xlabel('Steps')
plt.ylabel('Loss')
plt.legend()

# 画出学习率曲线
plt.subplot(212)
plt.plot(steps, learning_rate, label='Learning Rate')
plt.xlabel('Steps')
plt.ylabel('Learning Rate')
plt.legend()

# 显示图形
plt.show()