RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0.

报错内容

RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0.

RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 3 a nd 4 in dimension 1 at /opt/conda/conda-bld/pytorch_1532581333611/work/aten/src/TH/generic/THTensorMath.cpp:3616 

原来是因为数据集中都是224*224*3的图片,但是存在224*224*4的(不知道什么原因造成的),用cv2模块读不出来,但是用matplotlib.pyplot就可以读出来,因此,对这些维度错误的图片重新保存一遍即可解决问题

RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0.

在此特别感谢男朋友帮我调bug,嘻嘻嘻