使用 WandB 而不是单独的图来获取每个时期的对齐 val_loss 和 train_loss 图
我有以下代码,用于使用 WandB API 记录每个时期的训练和验证损失。但我不确定为什么我没有在同一时期得到 val 损失和训练损失。知道如何解决这个问题吗?
wandb.log({"train loss": train_epoch_loss,
"val loss": val_epoch_loss,
"epoch": epoch})
wandb.log({"train acc": train_epoch_acc,
"val acc": val_epoch_acc,
"epoch": epoch})
wandb.log({"best val acc": best_acc, "epoch": epoch})
I have the following code for logging the train and val loss in each epoch using WandB API. I am not sure though why I am not getting val loss and train loss in the same epoch. Any idea how that could be fixed?
wandb.log({"train loss": train_epoch_loss,
"val loss": val_epoch_loss,
"epoch": epoch})
wandb.log({"train acc": train_epoch_acc,
"val acc": val_epoch_acc,
"epoch": epoch})
wandb.log({"best val acc": best_acc, "epoch": epoch})
As you see, val loss vs epochs and train loss vs epochs are two completely separate entities while I would like to have both of them in one plot in WandB.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在Weights & 工作。偏差,很乐意提供帮助:
同一图表上的 2 个指标
要在同一图表上绘制 2 个指标,您可以单击图表中的铅笔图标进行编辑,然后将其他指标添加到 y-轴,如下图所示。
更改默认 x 轴
您还可以更改 X 轴以针对“epoch”而不是默认的 wandb
step
进行绘图。如果您希望默认情况下实现此行为,您可以在开始训练之前调用wandb.define_metric
一次,并将 x 轴设置为epoch
。请参阅define_metric文档了解更多记录步骤
需要注意的一件事是,当您记录验证指标时,您希望它们与训练指标在同一步骤中记录。在这种情况下,您可以执行以下操作:
或者,您可以使用
commit=
参数 用于存储指标而不增加 wandb 步骤。然后在需要时调用wandb.log
中的 Falsewandb.log()
来增加步长。I work at Weights & Biases, happy to help:
2 metrics on the same chart
To plot 2 metrics on the same chart you can click on the pencil icon in the chart to edit it, and then add additional metrics to the y-axis, as shown below.
Change default x-axis
You can also change the X axis to plot against "epoch" instead of the default wandb
step
. If you'd like this behaviour by default you can callwandb.define_metric
once before you start training and set the x-axis to beepoch
. See the define_metric docs for moreLogging step
One thing to be mindful of is that when you log your validation metrics, you'd like them to be logged at the same step as the train metrics. In this case you can do something like this:
Alternatively, you can use the
commit=False
argument inwandb.log
to store the metric without incrementing the wandb step. And then callwandb.log()
to increment the step when you need to.