JaimeTang / book-code

《深度学习之PyTorch实战计算机视觉》全书代码
128 stars 33 forks source link

第六章手写数字识别代码报错 #1

Closed xhy3054 closed 5 years ago

xhy3054 commented 5 years ago
tensor.sub_(mean[:, None, None]).div_(std[:, None, None])

RuntimeError: output with shape [1, 28, 28] doesn't match the broadcast shape [3, 28, 28]

以上是报错,似乎是mnist数据集是灰度图?然后代码中处理时将均值设置的是对rgb的图像进行的

JaimeTang commented 5 years ago

是的,书中错误了,需要把代码中的[0.5,0.5,0.5]替换成[0.5]就可以了。