当网络最后一层输出的
prediciton map size和label map size大小不匹配时,除了bilinea interpolation等暴力措施,且不采取unpooling,deconvolution等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 的两篇文章:
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 的 input4个input分别进行 2x2 的maxpooling 操作后,共产生了4个output。
最后,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填上来自output的pixel值,就是网络对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中心重叠的像素。