发布时间:2023-03-14 17:00
Pytorch 导入tersorboard 的 SummaryWriter时报错:raise ImportError(‘TensorBoard logging requires TensorBoard version 1.15 or above’)
ImportError: TensorBoard logging requires TensorBoard version 1.15 or above
或者
from torch.utils.tensorboard import SummaryWriter
ImportError: cannot import name ‘SummaryWriter’ from ‘torch.utils.tensorboard’
writer = SummaryWriter(\"logs\")
tensor_trans = transforms.ToTensor()
tensor_img = tensor_trans(img)
trans_resize = transforms.Resize((224, 224))
# PIL->(resize)->PIL
img_resize = trans_resize(tensor_img)
img_resize=img_resize.unsqueeze(0)
print(tensor_img.shape)
# input = torch.ones([1,1,224,224])
output=Su(img_resize)
writer.add_images(\"randomcorp\", output, 1)
writer.close()
例如:具体原因可能是因为自己的版本问题 或者 在自己的项目下存在同名(tensorboard.py)文件
版本问题:
pip install tensorboard=1.15.0 #1.15.0是版本 一般14.0以上都可以
同名问题:
#删除或修改同名py文件