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