【问题标题】:How to update AlexNet to use FCN? Confused on upsampling如何更新 AlexNet 以使用 FCN?对上采样感到困惑
【发布时间】:2020-11-23 02:48:18
【问题描述】:

主要问题是我不明白上采样的工作原理。 AlexNet 架构具有以下分类器

Dropout(),
Linear(in_features=9216, out_features=4096),
ReLU(),
Dropout(),
Linear(in_features=4096, out_features=4096),
ReLU(),
Linear(in_features=4096, out_features=1000)

上面是在 cifar 上使用的,所以类数是 1000。如果我们将分类器更改为使用 FCN(遵循FCN for Semantic Segmentation)并使用 VOC,我们将有 20 个类(为什么图中显示 21 个通道?)。图像大小调整为 256x256。论文中的架构如下所示

使用 pytorch 我有以下内容

class AlexNetFCN(nn.Module):

    def __init__(self):
        super().__init__()
        self.features = AlexNet().features
        self.classifier = nn.Sequential(
                nn.Dropout(),
                nn.Conv2d(256, 4096, kernel_size=6),
                nn.ReLU(),
                nn.Dropout(),
                nn.Conv2d(4096, 4096, kernel_size=1),
                nn.ReLU(),
                nn.Conv2d(4096, 20, kernel_size=1),
                )

    def forward(self, x):
        x = self.features(x)
        x = self.classifier(x)
        return x

我知道在特征部分之后我的图像是 7x7。如何上采样到 256x256?可能是nn.Bilinear,但我在论文中并不清楚。

【问题讨论】:

    标签: python deep-learning computer-vision pytorch semantic-segmentation


    【解决方案1】:

    您可以使用nn.Upsample 层,它是nn.functional.interpolate 函数的包装器(旧名称是nn.functional.upsample

    这是它在 alexnetfcn 实现中的使用方式:

    https://github.com/monaj07/pytorch_semseg/blob/e93e96f811bcdb45c8c88380f561e87d0ccbf514/ptsemseg/models/fcn.py#L145

    【讨论】:

      猜你喜欢
      • 2020-01-15
      • 1970-01-01
      • 2012-03-09
      • 2015-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多