writer.add_scalar(label,y,x)
from torch.utils.tensorboard import SummaryWriter
writer=SummaryWriter('logs')#path
for i in range(20):
writer.add_scalar('y=2x',2i,i)
writer.close()
运行:在终端内输入
tensorboard--logdir=logs --port=6007
writer.add_image(label,img,step,dataformat=‘HWC’)
img为array格式
from torch.utils.tensorboard import SummaryWriter
from PIL import Image
import numpy as np
writer=SummaryWriter('logs')#path
img_path='data/animaldata/train/ants_image/0013035.jpg'
img_PIL=Image.open(img_path)
img_np=np.array(img_PIL)
writer.add_image('test',img_np,1,dataformats='HWC')
writer.close()
|