Python 断言错误:输入张量的大小和输入格式不同。-张力板添加图像

Python 断言错误:输入张量的大小和输入格式不同。-张力板添加图像,python,pytorch,tensorboard,Python,Pytorch,Tensorboard,我试图在张力板上添加一个图像 img = Image.open(image_path) img = (np.asarray(img) / 255.0) img = torch.from_numpy(img).float() img = img.cuda().permute(2, 0, 1) img = img.cuda().unsqueeze(0) writer.add_image('Original', img) 但是有一个错误 张量形状:{},输入格式:{}。格式(tensor.sha

我试图在张力板上添加一个图像

img = Image.open(image_path)

img = (np.asarray(img) / 255.0)
img = torch.from_numpy(img).float()
img = img.cuda().permute(2, 0, 1)
img = img.cuda().unsqueeze(0)

writer.add_image('Original', img)
但是有一个错误

张量形状:{},输入格式:{}。格式(tensor.shape,输入格式) AssertionError:输入张量的大小和输入格式不同。张量形状:(1,3,420,629),输入格式:CHW