RuntimeError: size mismatch, m1: [32 x 2304], m2: [400 x 100] at C:/w/1/s/windows/pytorch/aten/srcTHC/generic/THCTensorMathBlas.cu:268

这个错误一般是卷积和全连接直接对接的时候,大小不匹配导致的。

可以查看卷积结束后 图片大小 ,然后对应修改全连接的输入大小即可。

    def forward(self,x):
        out = self.conv(x)
        out = out.view(out.size(0),-1)
        # print("-->{}".format(out.size()))
        out= self.fc(out)
        return out

  查看大小,然后修改自己的模型全连接的输入既可

原文地址:https://www.cnblogs.com/blogwangwang/p/12002304.html