【解决错误】The size of tensor a (8) must match the size of tensor b (64) at non-singleton dimension 1

一、报错

RuntimeError: Given groups=1, weight of size 64 64 1 1, expected input[16, 48, 40, 40] to have 64 channels, but got 48 channels instead

二、原因

  • 错误分析:这里面说的是要求输入的权重是[64,64,1,1],其中第二个维度的要求是64,但是给定的输入却是[16, 48, 40, 40],导致输入的第二个维度48和64不匹配。

三、解决方案

  • 一般出错都是在卷积层的输出的维度匹配不上下一个卷积层要求的输出维度,这时候我们要仔细检查上一层卷积的out_channel是否和下一层卷积的in_channel一模一样。
  • 当然还要注意concatenation拼接等操作引起的维度变化。

你可能感兴趣的:(ERROR集合,深度学习,学习笔记)