From 82847bc70ace49f9908029d242ad6dd3d5049c3c Mon Sep 17 00:00:00 2001 From: Megvii Engine Team <megengine@megvii.com> Date: Sat, 9 Jan 2021 12:48:15 +0800 Subject: [PATCH] docs(mge): add conv2d output shape computation formula GitOrigin-RevId: 7ee476a80d76f93451e20bab70ee6d534700cd9f --- imperative/python/megengine/module/conv.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/imperative/python/megengine/module/conv.py b/imperative/python/megengine/module/conv.py index 2bd957100..2c2ccb273 100644 --- a/imperative/python/megengine/module/conv.py +++ b/imperative/python/megengine/module/conv.py @@ -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. -- GitLab