【问题标题】:Replacing nn.Upsample with alternative upsample operation用替代上采样操作替换 nn.Upsample
【发布时间】:2020-06-08 12:48:29
【问题描述】:

我有一个UNet++私下查看,文章底部的模型代码),我正在尝试重新配置它。我在一些图像中得到了一些伪像,所以我关注this article,它建议先进行上采样,然后再进行卷积操作。

我正在用如下所示的顺序操作替换上采样层,但我的模型没有学习。我怀疑这与我如何配置频道有关,所以我想提出其他意见。

旧的上采样操作:

self.up = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True)

新操作:

class upConv(nn.Module):
"""
Up sampling/ deconv block by factor of 2 
"""
def __init__(self, in_ch, out_ch):
    super().__init__()
    self.upc = nn.Sequential(
                             nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True),
                             nn.Conv2d(in_ch, out_ch*2, 3, stride=1, padding=1),
                             nn.BatchNorm2d(out_ch*2),
                             nn.ReLU(inplace=True)
                             )
def forward(self, x):
    out = self.upc(x)
    return out

我的问题是这两个操作在我的模型中是否具有相同的输出/功能?

【问题讨论】:

    标签: computer-vision pytorch conv-neural-network deconvolution


    【解决方案1】:

    这两个操作在我的模型中是否具有相同的输出/功能?

    如果out_ch*2 == in_ch,那么:是的,它们具有相同的输出形状。

    如果输入 xBatchNorm+ReLU 操作的输出,那么它们可能更加相似。

    【讨论】:

    • 感谢您的确认,x 确实来自conv+BatchNorm+ReLU 操作。看起来这个问题根源于其他地方。
    猜你喜欢
    • 1970-01-01
    • 2020-11-21
    • 2014-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-28
    • 2018-07-14
    • 2016-01-12
    相关资源
    最近更新 更多