AssertionError: size of input tensor and input format are different.tensor shape: (64, 3, 32, 32)

AssertionError: size of input tensor and input format are different.
tensor shape: (64, 3, 32, 32), input_format: CHW

原因:tensor的维度是(64,3,32,32)而要求的输入格式是CHW,两者不匹配所以报错。

#报错
writer.add_image("test_data", imgs,step)

解决办法:用add_images方法替换add_image方法即可。

writer.add_images("test_data", imgs,step)

你可能感兴趣的:(python,pytorch,深度学习,python)