Transposed convolution

Transposed Convolution理解

转置卷积(反卷积)多用于上采样(UP Sample),可以将特征图尺寸由H*W*C变为2H*2W*C,达到扩大特征图的目的。用一句话来解释:

反卷积是一种特殊的正向卷积,先按照一定的比例通过补0来扩大输入图像的尺寸,接着旋转卷积核,再进行正向卷积。

一种错误的理解:转置卷积就是卷积的逆(Deconvolution)。实际上,**卷积是不可能求逆运算的!**所谓的转置卷积(Transposed Convolution)只是将特征图尺寸变大一倍,并不能还原特征图,所以卷积是没有逆运算的。

那么转置卷积(Transposed Convolution)是怎么样实现的呢?

1、卷积

先看看卷积,如下图,图中蓝色(下面)是输入,绿色(上面)是输出。
正向卷积

2、转置卷积

转置卷积

3、Transposed Convolution理解

实际上,转置卷积就是现在特征图中补0(zero padded,并且padding=kernel size-1),然后再做一次正向卷积。当然,实际实现中使用稀疏矩阵即可,这样避免了无用的补0之后与kernel相乘的操作。
最后,转置卷积kernel的参数是可以学习的,会训练过程不断被优化,不需要人为设定,也并不是正向卷积kernel的转置!

Transposed convolution with stride greater than one can be imagined as inserting zeros between elements of input tensor and sliding a convolution kernel over it. This increases the tensor’s size. Bear in mind that doing this in a straightforward manner is inefficient, but conceptually it is how transpose convolution works. Real implementations avoid useless multiplications by zero and compute it as sparse matrix multiplication with weight matrix transposed from weight matrix representation of convolution operation with equal stride.

  • 推荐阅读:
    https://blog.csdn.net/loseinvain/article/details/81098502(写得很好)

  • 参考资料:
    1、https://zhuanlan.zhihu.com/p/48501100
    2、https://deepsense.ai/satellite-images-semantic-segmentation-with-deep-learning/