小编Red*_*Red的帖子

RuntimeError:给定 groups=1,权重大小为 [32, 3, 16, 16, 16],预期输入 [100, 16, 16, 16, 3] 有 3 个通道,但得到了 16 个通道

RuntimeError:给定 groups=1,权重大小为 [32, 3, 16, 16, 16],预期输入 [100, 16, 16, 16, 3] 有 3 个通道,但得到了 16 个通道

这是我认为问题所在的代码部分。

def __init__(self):
        super(Lightning_CNNModel, self).__init__()

        self.conv_layer1 = self._conv_layer_set(3, 32)
        self.conv_layer2 = self._conv_layer_set(32, 64)
        self.fc1 = nn.Linear(2**3*64, 128)
        self.fc2 = nn.Linear(128, 10)   # num_classes = 10
        self.relu = nn.LeakyReLU()
        self.batch=nn.BatchNorm1d(128)
        self.drop=nn.Dropout(p=0.15)

    def _conv_layer_set(self, in_c, out_c):
        conv_layer = nn.Sequential(
            nn.Conv3d(in_c, out_c, kernel_size=(3, 3, 3), padding=0),
            nn.LeakyReLU(),
            nn.MaxPool3d((2, 2, 2)),
        )

        return conv_layer



    def forward(self, x):
        out = self.conv_layer1(x)
        out = self.conv_layer2(out)
        out = out.view(out.size(0), -1) …
Run Code Online (Sandbox Code Playgroud)

python conv-neural-network pytorch pytorch-lightning

14
推荐指数
1
解决办法
3万
查看次数