tensorboard中一个函数多图
时间: 2023-12-04 18:33:02 浏览: 65
解决tensorboard多个events文件显示紊乱的问题
5星 · 资源好评率100%
显示不同颜色的曲线,该怎么做?
首先,您需要在代码中定义每个曲线的名称和颜色,然后将它们传递给 tensorboard.writer.add_scalar 函数以进行记录。例如:
```
from torch.utils.tensorboard import SummaryWriter
# Define curve names and colors
curve1_name = 'Curve 1'
curve1_color = 'red'
curve2_name = 'Curve 2'
curve2_color = 'blue'
# Initialize writer
writer = SummaryWriter()
# Record curves
for i in range(10):
# Record curve 1
curve1_val = i * 2
writer.add_scalar(curve1_name, curve1_val, i, color=curve1_color)
# Record curve 2
curve2_val = i**2
writer.add_scalar(curve2_name, curve2_val, i, color=curve2_color)
# Close writer
writer.close()
```
在 tensorboard 中,您可以通过选择“Runs”选项卡,然后从下拉菜单中选择当前记录的运行以查看记录的曲线。您应该能够看到两条曲线,其中一条为红色,另一条为蓝色。
阅读全文