[AssertionError: nput tensor input format are different]
生活随笔
收集整理的這篇文章主要介紹了
[AssertionError: nput tensor input format are different]
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
問題描述
writer.add_image('img/fixed_img', denorm(fixed_img.data), 0)報如下錯誤
assert(len(tensor.shape) == len(input_format)), "size of input tensor and input format are different.AssertionError: size of input tensor and input format are different. tensor shape: (128, 3, 64, 64), input_format: CHW
從報錯信息來看, input tensor的維度是(128, 3, 64, 64),而 input_format的格式需要是 CHW。兩者不匹配。
分析到這兒就明白了。input tensor雖然格式也是CHW, 但它還有一個batch維度,所以報錯。
add_image只接收單一圖像,你給它傳一個batch數據自然是不行的
解決辦法
add_images?替換add_image就可以顯示batch數據了
總結
以上是生活随笔為你收集整理的[AssertionError: nput tensor input format are different]的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AttributeError: ‘set
- 下一篇: 读书笔记——信息的表示与处理