SummaryWriter和tensorboard使用示例

from torch.utils.tensorboard import SummaryWriter
import numpy as np
from PIL import Image

writer = SummaryWriter("logs")
image_path = "dataSet/train/ants/0013035.jpg"
img_PIL = Image.open(image_path)
img_array = np.array(img_PIL)
writer.add_image("test", img_array, 1, dataformats="HWC")

for i in range(100):
    writer.add_scalar("y=x", i, i)

writer.close()

运行后产生logs文件

然后命令行输入 tensorboard --logdir 'NeuralNetwork/test/logs'

你可能感兴趣的:(python,开发语言,后端)