Deep learning 在pytorch中实现DCGAN时出错:内核大小可以';不能大于实际输入大小

Deep learning 在pytorch中实现DCGAN时出错:内核大小可以';不能大于实际输入大小,deep-learning,pytorch,conv-neural-network,generative-adversarial-network,dcgan,Deep Learning,Pytorch,Conv Neural Network,Generative Adversarial Network,Dcgan,我一直在尝试在PyTorch中培训DCGAN实现。我得到以下错误: 运行时错误:每个通道计算的填充输入大小:(3 x 3)。内核大小:(4 x 4)。内核大小不能大于实际输入大小 我修改了中定义的鉴别器网络 修改后的鉴别器网络如下所示: self.main = nn.Sequential( nn.Conv2d(nc, ndf, 4, 2, 1, bias=False), nn.LeakyReLU(0.2, inplace=T

我一直在尝试在PyTorch中培训DCGAN实现。我得到以下错误:

运行时错误:每个通道计算的填充输入大小:(3 x 3)。内核大小:(4 x 4)。内核大小不能大于实际输入大小

我修改了中定义的鉴别器网络

修改后的鉴别器网络如下所示:

self.main = nn.Sequential(
           
            nn.Conv2d(nc, ndf, 4, 2, 1, bias=False),
            nn.LeakyReLU(0.2, inplace=True),
            
            nn.Conv2d(ndf, ndf * 2, 4, 2, 1, bias=False),
            nn.BatchNorm2d(ndf * 2),
            nn.LeakyReLU(0.2, inplace=True),
            
            nn.Conv2d(ndf * 2, ndf * 4, 4, 2, 1, bias=False),
            nn.BatchNorm2d(ndf * 4),
            nn.LeakyReLU(0.2, inplace=True),
            
            nn.Conv2d(ndf * 4, ndf * 8, 4, 2, 1, bias=False),
            nn.BatchNorm2d(ndf * 8),
            nn.LeakyReLU(0.2, inplace=True),
            
            nn.Conv2d(ndf * 8, ndf * 8, 4, 2, 1, bias=False),
            nn.BatchNorm2d(ndf * 8),
            nn.LeakyReLU(0.2, inplace=True),
            
            nn.Conv2d(ndf * 8, ndf * 16, 4, 2, 1, bias=False),
            nn.BatchNorm2d(ndf * 16),
            nn.LeakyReLU(0.2, inplace=True),
            
            nn.Conv2d(ndf * 16, ndf * 16, 4, 2, 1, bias=False),
            nn.BatchNorm2d(ndf * 16),
            nn.LeakyReLU(0.2, inplace=True),
            
            nn.Conv2d(ndf * 16, 1, 4, 1, 0, bias=False),
            nn.Sigmoid()
        )

提前谢谢

错误可能不在这里,而是在您将输入传递到序列数据库的方式中。填充图像太小,只有3x3像素,因此您不能使用内核4x4。@谢谢分享。我仍然无法调试它。代码的其余部分与相同。我刚刚尝试修改图层。