深度学习学习日记_FCN_(1) shift_and_stitch

当网络最后一层输出的 prediciton map size 和 label map size 大小不匹配时,除了bilinea interpolation 等暴力措施,且不采取 unpoolingdeconvolution 等decoder 结构, 为了实现 dense prediction , 该怎么做呢?

Fully Convolutional Networks for Semantic Segmentation》为了实现dense prediction ,他们比较了三种不同方案,分别是 shift and stitch, decreasing subsampling,deconvolution

作者对 shift and stitch 的描述是:

网上的关于shift-and-stitch的解释:设原图与FCN所得输出图之间的降采样因子是f,那么对于原图的每个fxf 的区域(不重叠),“shift the input x pixels to the right and y pixels down for every (x,y) ,0 < x,y < f." 把这个f x f区域对应的output作为此时区域中心点像素对应的output,这样就对每个 fxf 的区域得到了 f2 个output,也就是每个像素都能对应一个output,所以成为了dense prediction

我看了作者 引用 的关于 shift and stitch 的两篇文章:

[28] P. H. Pinheiro and R. Collobert. Recurrent convolutional
neural networks for scene labeling
. In ICML, 2014

[29] P. Sermanet, D. Eigen, X. Zhang, M. Mathieu, R. Fergus,
and Y. LeCun. Overfeat: Integrated recognition, localization
and detection using convolutional networks
. In ICLR, 2014.

shift and stitch的做法其实就是:

设降采样因子是f , 通过 shift pixels (平移像素)的方式,产生 f2 个version 的 input ,输入网络后相应地产生 f2 个output, 然后 stitch(这个词不好翻译,先翻译成织联)所有 output 就实现了 dense prediciton

在另一篇论文中找到了对shift and stitch 更详尽的描述 :

 

接下来受论文[2] 的启发,我们举一个简单的例子来直观地说明 shift and stitch 的做法:

设网络只有一层 2x2 的maxpooling 层且 stride = 2,所以下采样因子 f =2, 我们需要对input image 的 pixels 平移 (x,y)个单位,即将 image 向左平移 x 个pixels , 再向上平移y个单位,整幅图像表现向左上方向平移,空出来的右下角就以0 padding 。我们当然可以采取 FCN论文中的做法,将图像向右下角平移,空出来的左上角用 0 padding ,这两种做法产生的结果是一致的,没有本质区别。(x,y) 取(0,0), (0,1),(1,0),(1,1) 后,就产生了 f^2^ = 4 个input,不妨记为: shifted input (0,0)shifted input (0,1)shifted input (1,0)shifted input (1,1)(回答一个读者的问题:图中的数字表示像素值,不是索引值 )

shift the pixels of original image, 产生4个version 的 input4input分别进行 2x2 的maxpooling 操作后,共产生了4output

最后,stitch the 4 different output 获得 dense prediction :

那么问题来了,是怎样进行 stitch的呢?FCN 作者的说法是:

Process each of these f2 inputs, and interlace the outputs so that the predictions correspond to the pixels at the centers of their receptive fields

说的很明白了,output 中的每个pixel都对应 original image 的不同 receptive field,将receptive field 的中心c填上来自outputpixel值,就是网络对original image 中像素 c类别的prediction

为表述简洁,我用 “ 像素 i ” 表示“ 值为 i 的像素 ”

  • 红色 output中的像素1对应shifted input(0,0) 的红色部分, 而对应 original image 的部分,也即receptive field仅仅为像素[1], 所以 receptive field 的中心为像素[1], 该位置填上红色output中像素 1 的值。

  • 黄色 output 中的像素4 对应 shifted input (1,0)的黄色部分, 而对应 original image 的部分,也即receptive field为像素 [3,4] , 所以 receptive field 的中心为像素 [4], 该位置填上黄色output中像素 4 的值。

  • 以此类推..

  • 注意: 我们注意到黄色 output 中的像素 5 与红色 output 中的像素5对应的receptive field中心是重叠的,所以将黄色 output 中的像素 5 标为灰色,表示不予考虑。同理其他ouput 中的灰色区域也代表 receptive field中心重叠的像素。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值