Convolution and Transposed

This is a exhaustive paper for different kind of convolution computation, but the arithmetic is not enough.

The paper: https://arxiv.org/abs/1603.07285

The Github(including gifs):https://github.com/vdumoulin/conv_arithmetic

Introduction

Relationship of conv and it’s trans

We define $i$ as input size, $o$ as output size, $k$ as kernel size, $s$ as stride size, $p$ as padding size, and $x^{‘}$ ($x={i,o,p,k,s}$) as transposed operation parameters.

$o=i^{‘}$ $i=o^{‘}$ $k^{‘}=k$ is obvious.

$o=\frac{i-k+2p}{s}+1$ is also obvious, its called Equation1.

$o^{‘}=\frac{i^{‘}-k^{‘}+2p{‘}}{s^{‘}}+1$ called Equation2.

When $s^{‘}=s=1$, We will get $p^{‘}=k-p-1$;

And when $s>1$, to get a solution, we set the $i^{‘}_{new}=o+(o-1) \times m$, which $m$ cells will be inserted into every cell in original feature map. Like photo below.

image-20200901101607724

After simplification, there will be:

$(1+m)\frac{s^{‘}}{s}=1$, called Equation 3;

$(1+m)(\frac{2p-k}{s}+1)-m-k+2p^{‘}+s^{‘}=0$,called Equation 4.

We will get:

$m=\frac{s}{s^{‘}}-1$ and $2p-k+s^{‘}-ks^{‘}+2p^{‘}s^{‘}+s^{‘2}=0$.

Obviously, 2 equations and 3 paras, let s=$s^{‘}=1$, a viable solution is $m=s-1 \space p^{‘}=k-p-1$. That’s enough.