我正在尝试训练体积数据,我分别发送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