RuntimeError:给定输入大小:(32x1x30x246)。计算的输出大小:(32x-1x28x244)。输出大小太小

时间:2020-01-25 13:03:26

标签: pytorch conv-neural-network

我正在尝试训练体积数据,我分别发送61个形状为[1、1、20、256、256]的形状。线性图层似乎不匹配,请看看。

型号:

class AlexNet(nn.Module):

    def __init__(self, num_classes=100):
        super(AlexNet, self).__init__()
        self.features = nn.Sequential(
            nn.Conv3d(1, 16, kernel_size=(11,11,11), stride=(4,4,1), padding=(1,1,1)),
            nn.ReLU(inplace=True),
            nn.MaxPool3d(kernel_size=(3,3,3), stride=(2,2,1)),
            nn.Conv3d(16, 32, kernel_size=(3,3,3), padding=(1,1,1)),
            nn.ReLU(inplace=True),
            nn.MaxPool3d(kernel_size=(3,3,3), stride=(1,1,1)),
            nn.Conv3d(32, 64, kernel_size=(3,3,3), padding=(1,1,1)),
            nn.ReLU(inplace=True),
            nn.Conv3d(64, 128, kernel_size=(3,3,3), padding=(1,1,1)),
            nn.ReLU(inplace=True),
            nn.Conv3d(128, 256, kernel_size=(3,3,3), padding=(1,1,1)),
            nn.ReLU(inplace=True),
            nn.MaxPool3d(kernel_size=(3,3,1), stride=(2,2,1)),
        )
        self.classifier = nn.Sequential(
            nn.Dropout(),
            nn.Linear(236160, 4096),
            nn.ReLU(inplace=True),
            nn.Dropout(),
            nn.Linear(4096, 4096),
            nn.ReLU(inplace=True),
            nn.Linear(4096, num_classes),
        )

    def forward(self, x):
        x = self.features(x)
        x = x.view(x.size(0), 192 * 1 * 31 * 256)
        x = self.classifier(x)
        return x

0 个答案:

没有答案