JaimeTang/book-code

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

Closed this issue · 1 comments

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的图像进行的

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