How to calculate the size after three types of convolution (ordinary convolution, transposed convolution, dilated convolution)


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

Insert image description here

Ordinary convolution is relatively simple, and its calculation method is as follows:
Insert image description here

2. Transposed convolution

Insert image description here
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:
Insert image description here
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.
Insert image description here
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,
Insert image description here
and calculate the size after atrous convolution is
Insert image description here
This also corresponds to the pytorch documentation
Insert image description here


Guess you like

Origin blog.csdn.net/weixin_47250738/article/details/133275770