Browse Source

docs(mge): add conv2d output shape computation formula

GitOrigin-RevId: 7ee476a80d
release-1.2
Megvii Engine Team 4 years ago
parent
commit
82847bc70a
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      imperative/python/megengine/module/conv.py

+ 13
- 0
imperative/python/megengine/module/conv.py View File

@@ -247,6 +247,19 @@ class Conv2d(_ConvNd):
:math:`H` is height of input planes in pixels, and :math:`W` is
width in pixels.

In general, output feature maps' shapes can be inferred as follows:

input: :math:`(N, C_{\text{in}}, H_{\text{in}}, W_{\text{in}})`
output: :math:`(N, C_{\text{out}}, H_{\text{out}}, W_{\text{out}})` where

.. math::
\text{H}_{out} = \lfloor \frac{\text{H}_{in} + 2 * \text{padding[0]} -
\text{dilation[0]} * (\text{kernel_size[0]} - 1)}{\text{stride[0]}} + 1 \rfloor

.. math::
\text{W}_{out} = \lfloor \frac{\text{W}_{in} + 2 * \text{padding[1]} -
\text{dilation[1]} * (\text{kernel_size[1]} - 1)}{\text{stride[1]}} + 1 \rfloor

When `groups == in_channels` and `out_channels == K * in_channels`,
where K is a positive integer, this operation is also known as depthwise
convolution.


Loading…
Cancel
Save