画y=5x的直线图,代码如下:
from torch.utils.tensorboard.writer import SummaryWriter
writer = SummaryWriter("logs")
# writer.add_image()
#y = 5x
for i in range(100):
writer.add_scalar('Function y=5x', i*5, i)
writer.close()
## 打开图片
# terminal 里输入 tensorboard --logdir="D:\practice\pycharmpra\test1\learn_torch\logs"
# terminal 里输入 tensorboard --logdir="logs"
# terminal 里输入 tensorboard --logdir=logs
运行结果皆为:
没有坐标图形
以下做法亲测可用
# terminal 里输入 tensorboard --logdir=D:\practice\pycharmpra\test1\learn_torch\logs
注意:tensorboard和–之间1个空格,=(等号)后面是图片的绝对地址,地址不加引号!