B站大学的PyTorch深度学习快速入门教程(绝对通俗易懂!)【小土堆】 的P7P8讲讲述了TensorBoard的使用。
from torch.utils.tensorboard import SummaryWriter
import numpy as np
from PIL import Image
writer = SummaryWriter("logs")
image_path = "data/val/ants/10308379_1b6c72e180.jpg"
img_PIL = Image.open(image_path)
img_array = np.array(img_PIL)
print(type(img_array))
print(img_array.shape)
writer.add_image("train", img_array, 1, dataformats='HWC')
for i in range(100):
writer.add_scalar("y=2x", 3*i, i)
writer.close()
此程序可以实现如图功能:在网页中展示了两个深度学习的图片。
|