Machine-Deep-Learning icon indicating copy to clipboard operation
Machine-Deep-Learning copied to clipboard

一些关于分割任务的记录

Open ghost opened this issue 6 years ago • 5 comments

ghost avatar Dec 13 '18 07:12 ghost

FCN中deconv是初始化与前面的conv不同么?

        for m in self.modules():
            if isinstance(m, nn.Conv2d) or isinstance(m, nn.Linear):
                m.weight.data.normal_(0.0, 0.01)
                m.bias.data.fill_(0)
            if isinstance(m, nn.ConvTranspose2d):
                assert m.kernel_size[0] == m.kernel_size[1]
                initial_weight = get_upsampling_weight(
                    m.in_channels, m.out_channels, m.kernel_size[0])
                m.weight.data.copy_(initial_weight)

学姐的代码里这里的对于转置卷积的初始化操作有些特别, 不太理解。

def get_upsampling_weight(in_channels, out_channels, kernel_size):
    """Make a 2D bilinear kernel suitable for upsampling"""
    factor = (kernel_size + 1) // 2
    if kernel_size % 2 == 1:
        center = factor - 1
    else:
        center = factor - 0.5
    og = np.ogrid[:kernel_size, :kernel_size]
    filt = (1 - abs(og[0] - center) / factor) * \
           (1 - abs(og[1] - center) / factor)
    weight = np.zeros((in_channels, out_channels, kernel_size, kernel_size),
                      dtype=np.float64)
    weight[range(in_channels), range(out_channels), :, :] = filt
    return torch.from_numpy(weight).float()

我们将2x上采样初始化为双线性插值, 但允许按照3.3节所述学习参数( We initialize the upsampling tobilinear interpolation, but allow the parameters to be learnedas described in Section 3.3.)

这里使用的双线性插值的方式来进行的初始化.

lartpang avatar Dec 15 '18 03:12 lartpang

从某种意义上,伴随因子f的上采样是对步长为1/f的分数式输入的卷积操作。只要f是整数,一种自然的方法进行上采样就是向后卷积(有时称为去卷积)伴随输出步长为f。这样的操作实现是不重要的,因为它只是简单的调换了卷积的顺推法和逆推法。所以上采样在网内通过计算像素级别的损失的反向传播用于端到端的学习。

需要注意的是去卷积滤波在这种层面上不需要被固定不变(比如双线性上采样)但是可以被学习。一堆反褶积层和激励函数甚至能学习一种非线性上采样。在我们的实验中,我们发现在网内的上采样对于学习dense prediction是快速且有效的

lartpang avatar Dec 15 '18 03:12 lartpang

可以从最近的相关的论文中了解过去这些年的语义分割方法的发展历史.

https://www.groundai.com/project/pyramid-attention-network-for-semantic-segmentation/#section_3

ghost avatar Dec 20 '18 02:12 ghost

总结:

  • 语义分割体系结构的另一个重要方面是使用学习好的deconvolutions对低分辨率分割图进行特征图上采样以获得输入图像分辨率的机制,或者在编码器中使用以计算为代价的扩张卷积来避免部分的分辨率下降。即使在现代GPU上,扩张卷积(Dilated convolutions )也非常昂贵。
    • 这篇关于distill.pub的文章解释了有关反卷积的更多细节。

不同的网络如何实现上采样

  • FCN 双线性插值初始化(虽然还不理解), 分数卷积实现上采样, 这个应该就是转置卷积.
  • SegNet 使用对应的最大值索引进行恢复, 变成稀疏的特征图, 再利用后接的卷积实现进一步的密集化 [unpooling]
    • 虽然这有助于保持高频信息的完整性,但是当从低分辨率特征图中unpooling时,它也会错过相邻的信息。
  • Deeplab 通过空洞卷积的组合来恢复全分辨率的特征映射,这种方法计算的特征映射更加密集,然后简单地对特征的响应进行双线性插值恢复到原始图像大小
  • U‐Net 2x2卷积外围补零, 实现的上采样
    • 通过其跳过concatenation连接的架构允许每个阶段的解码器学习在编码器中池化时丢失的相关特征。
  • RefineNet 上采样是在Multi-resolution fusion单元完成的, 这里感觉更像是使用的双线性插值
  • PSPNet 双线性插值直接对低维特征映射进行上采样,以获得与原始特征图相同的大小特征, 最后,不同级别的特征被连接为最终的金字塔池化全局特征。
    • image
  • Mask‐RCNN 不需要上采样, 因为它是基于Faster R-CNN的, 所有预测的结果都是针对于原始图像大小的.
  • Efficient Sub-Pixel Convolutional Neural Network: 亚像素卷积,
    • image
  • Decoders Matter for Semantic Segmentation:Data-Dependent Decoding Enables Flexible Feature Aggregation: DUpsample
    • image

ghost avatar Dec 20 '18 08:12 ghost

条件随机场

image

image

image

image

image

image

image

image

image

image

维特比算法

维特比算法是基于当前所有存在的要考虑的节点中的最优子路径, 计算寻找出到达下一批节点的最优路径(每个下一批次的节点都有一个对应的最有结果).

image

最后总的从结果中取最优的路径.

这个算法在log-model, MEMMs, CRFs中都起到关键作用

ghost avatar Dec 21 '18 03:12 ghost