Article directory
Preface
How to calculate the size of the feature map after three convolutions. Including ordinary convolution, transposed convolution, and dilated convolution. You can see the dynamic diagrams of the three convolutions at the link below.
Convolution dynamic graph
1. Ordinary convolution
Ordinary convolution is relatively simple, and its calculation method is as follows:
2. Transposed convolution
First, we must understand the calculation process of transposed convolution. The parameters p and s have different meanings from ordinary convolution.
The calculation process is as follows:
Be sure to understand that p and s of its species have different meanings from p and s of ordinary convolution species . Once you understand its operation process, let's look at how to calculate the size after convolution.
This matches the calculation formula in the pytorch documentation.
H=(H−1)×stride[0]−2×padding[0]+dilation[0]×(kernel_size[0]−1)+output_padding[0]+1
Ignore dilation, default is 1, ignore output_padding, default is 0.
When using transposed convolution for upsampling, s is usually set equal to the upsampling multiple, and then the values of k and p are specified.
3. Atrous convolution
Atrous convolution is to fill 0 between the convolution kernels, fill (r-1) rows (r-1) columns,
and calculate the size after atrous convolution is
This also corresponds to the pytorch documentation