tensorboard:展示训练结果,比如loss的变换过程
from torch.utils.tensorboard import SummaryWriter
import numpy as np
from PIL import Image
writer = SummaryWriter("logs") #创建SummaryWriter类的实例
imge_path=""
img_PIL = Image.open(image_path)
img_array = np. array(img_PIL)
print(type(img_array))
print(img_array.shape)
writer.add_image("test", img_array, 1, dataformats = "HWC") #add.image()常用来查看训练结果
#要求image是numpy型,tensor类型
# scalar_value :y轴
#global_step : x轴
# y =x
for i in range(100):
write.add_scalar("y=x", i, i)
write.close
# terminal : tensorboard --logdir=logs
指定端口名:tensorboard --logdir=logs --port=6007