sard74 2021-12-13 15:11 采纳率: 0%
浏览 455
已结题

Given groups=1 weight of size [64 64 3 3] expected input[4 67 256 256] to have 64 channels but 67

我知道是网络层发生的问题,查看了网络层,但是实在不懂到底是哪里多了3个channels,急!

def init(self, ngf2=64, num_res_blocks=16, num_upsample=2):
super(Generator, self).init()

    self.conv0 = nn.Conv2d(in_channels=3,out_channels=ngf2, kernel_size=3, padding=1)
    # First layer
    self.conv1 = nn.Conv2d(in_channels=ngf2,out_channels=ngf2, kernel_size=3, padding=1, stride=1)
    # Residual blocks
    self.res_blocks = nn.Sequential(*[ResidualInResidualDenseBlock(ngf2) for _ in range(num_res_blocks)])
    # Second conv layer post residual blocks
    self.conv2 = nn.Conv2d(in_channels=ngf2, out_channels = ngf2, kernel_size=3, stride=1, padding=1)
    # Upsampling layers
    upsample_layers = []
    for _ in range(num_upsample):
        upsample_layers += [
            nn.Conv2d(ngf2, ngf2 * 4, kernel_size=1, stride=2, padding=1),
            nn.LeakyReLU(),
            nn.PixelShuffle(upscale_factor=2),
        ]
    self.upsampling = nn.Sequential(*upsample_layers)
    # Final output block
    self.conv3 = nn.Sequential(
        nn.Conv2d(in_channels=ngf2, out_channels = ngf2, kernel_size=5, stride=1, padding=1),
        nn.LeakyReLU(),
        nn.Conv2d(in_channels=ngf2, out_channels =64, kernel_size=5, padding=1, stride=1),
    )
    #self.conv4 = nn.Conv2d(out_channels=64, kernel_size=3, padding=1, in_channels=6)

def forward(self, x):
    out0 = self.conv0(x)
    out1 = self.conv1(out0)
    out = self.res_blocks(out1)
    out2 = self.conv2(out)
    out = torch.add(out1, out2)
    out = self.upsampling(out)
    out = self.conv3(out)
   # out = self.conv4(out)
    return out
  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 12月21日
    • 创建了问题 12月13日

    悬赏问题

    • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
    • ¥15 setInterval 页面闪烁,怎么解决
    • ¥15 如何让企业微信机器人实现消息汇总整合
    • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
    • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
    • ¥15 TLE9879QXA40 电机驱动
    • ¥20 对于工程问题的非线性数学模型进行线性化
    • ¥15 Mirare PLUS 进行密钥认证?(详解)
    • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
    • ¥20 想用ollama做一个自己的AI数据库