本文主要轉自:https://zhuanlan.zhihu.com/p/41427866
語義分割中的FCN、U-Net,目標檢測中的FPN、DSSD、YOLOV3等模型爲了增強模型效果,都會通過hour glass結構來融合低層和高層的信息,這樣融合後的特徵既具有高層特徵的抽象語意信息,又具有低層特徵的細節信息。而低層特徵feature map比高層特徵feature map大,爲了融合,需要將高層特徵feature map放大到跟低層特徵feature map一樣大,放大feature map的過程也就是升採樣(upsample)過程,如下圖所示。升採樣具體實現有插值方式和deconv方式。
升採樣示意圖
一、插值
插值常用的方式有nearest interpolation、bilinear interpolation、bicubic interpolation。
1、nearest interpolation
將離待插值最近的已知值賦值給待插值。
2、bilinear interpolation
根據離待插值最近的 2*2個已知值來計算待插值,每個已知值的權重由距離待插值距離決定,距離越近權重越大。示意圖和計算公式如下所示。
bilinear interpolation示意圖
bilinear interpolation計算過程
3、bicubic interpolation
根據離待插值最近的 4*4個已知值來計算待插值,每個已知值的權重由距離待插值距離決定,距離越近權重越大。示意圖如下所示。
bicubic interpolation
4、各種插值方式的區別與聯繫
從nearest interpolation、bilinear interpolation到bicubic interpolation,插值所利用的信息越來越多,feature map越來越平滑,但是同時計算量也越來越大,nearest interpolation、bilinear interpolation、bicubic interpolation的區別與聯繫可見下圖示意,其中黑色的點爲預測值,其他彩色點爲周圍已知值,用來計算預測值。
各種插值方式的區別與聯繫
二、deconv
自從步入深度學習時代,我們越來越追求end2end,那麼升採樣能不能不用人爲定義的權重,而讓模型自己學習呢?答案是顯然的,deconv就是解決方案之一。
1、stride=1
等價於stride=1的conv,只是padding方式不同,不能起到升採樣的作用。以一維的數據爲例,示意圖如下,中間步驟是將卷積轉換爲矩陣乘法的過程。
stride=1的deconv計算過程
2、stride > 1
能起到升採樣的作用,一般用到的deconv,stride都大於1。以一維的數據爲例,示意圖如下,中間步驟是將卷積轉換爲矩陣乘法的過程。
stride=2的deconv計算過程
3、名字
deconvolution也叫transposed convolution,upconvolution等等。其中deconvolution這個名字有點歧義性,容易帶來困惑,transposed convolution比較容易理解。容易驗證1和2中convolution和deconvolution中的權重矩陣互爲轉置。
三、deconv和插值的區別與聯繫
deconv和插值,都是通過周圍像素點來預測空白像素點的值,區別在於一個權重由人爲預先定義的公式計算,一個通過數據驅動來學習。
詳細區別分析還可參考我自己的博客:https://blog.csdn.net/zl3090/article/details/104815357
四、參考:
https://distill.pub/2016/deconv-checkerboard
https://www.cambridgeincolour.com/tutorials/image-interpolation.htm
http://cs231n.stanford.edu/slides/2018/cs231n_2018_lecture11.pdf