forked from mindspore-Ecosystem/mindspore
correct conv ops api equations
This commit is contained in:
parent
a028a42c88
commit
7c472435e4
|
@ -45,28 +45,28 @@ mindspore.nn.Conv2d
|
|||
|
||||
.. math::
|
||||
\begin{array}{ll} \\
|
||||
H_{out} = \left \lfloor{\frac{H_{in}}{\text{stride[0]}} + 1} \right \rfloor \\
|
||||
W_{out} = \left \lfloor{\frac{W_{in}}{\text{stride[1]}} + 1} \right \rfloor \\
|
||||
H_{out} = \left \lceil{\frac{H_{in}}{\text{stride[0]}}} \right \rceil \\
|
||||
W_{out} = \left \lceil{\frac{W_{in}}{\text{stride[1]}}} \right \rceil \\
|
||||
\end{array}
|
||||
|
||||
pad_mode为"valid"时:
|
||||
|
||||
.. math::
|
||||
\begin{array}{ll} \\
|
||||
H_{out} = \left \lfloor{\frac{H_{in} - \text{dilation[0]} \times (\text{kernel_size[0]} - 1) }
|
||||
{\text{stride[0]}} + 1} \right \rfloor \\
|
||||
W_{out} = \left \lfloor{\frac{W_{in} - \text{dilation[1]} \times (\text{kernel_size[1]} - 1) }
|
||||
{\text{stride[1]}} + 1} \right \rfloor \\
|
||||
H_{out} = \left \lceil{\frac{H_{in} - \text{dilation[0]} \times (\text{kernel_size[0]} - 1) }
|
||||
{\text{stride[0]}}} \right \rceil \\
|
||||
W_{out} = \left \lceil{\frac{W_{in} - \text{dilation[1]} \times (\text{kernel_size[1]} - 1) }
|
||||
{\text{stride[1]}}} \right \rceil \\
|
||||
\end{array}
|
||||
|
||||
pad_mode为"pad"时:
|
||||
|
||||
.. math::
|
||||
\begin{array}{ll} \\
|
||||
H_{out} = \left \lfloor{\frac{H_{in} + padding[0] + padding[1] - (\text{dilation[0]} - 1) \times
|
||||
\text{kernel_size[0]} - 1 }{\text{stride[0]}} + 1} \right \rfloor \\
|
||||
W_{out} = \left \lfloor{\frac{W_{in} + padding[2] + padding[3] - (\text{dilation[1]} - 1) \times
|
||||
\text{kernel_size[1]} - 1 }{\text{stride[1]}} + 1} \right \rfloor \\
|
||||
H_{out} = \left \lfloor{\frac{H_{in} + padding[0] + padding[1] - (\text{kernel_size[0]} - 1) \times
|
||||
\text{dilation[0]} - 1 }{\text{stride[0]}} + 1} \right \rfloor \\
|
||||
W_{out} = \left \lfloor{\frac{W_{in} + padding[2] + padding[3] - (\text{kernel_size[1]} - 1) \times
|
||||
\text{dilation[1]} - 1 }{\text{stride[1]}} + 1} \right \rfloor \\
|
||||
\end{array}
|
||||
|
||||
异常:
|
||||
|
|
|
@ -12,7 +12,7 @@ mindspore.ops.Conv2D
|
|||
|
||||
其中, :math:`ccor` 为 `cross-correlation <https://en.wikipedia.org/wiki/Cross-correlation>`_ , :math:`C_{in}` 为输入通道数, :math:`j` 的范围从 :math:`0` 到 :math:`C_{out} - 1` , :math:`W_{ij}` 对应第 :math:`j` 个过滤器的第 :math:`i` 个通道, :math:`out_{j}` 对应输出的第 :math:`j` 个通道。 :math:`W_{ij}` 为卷积核的切片,其shape为 :math:`(\text{kernel_size[0]},\text{kernel_size[1]})` ,其中 :math:`\text{kernel_size[0]}` 和 :math:`\text{kernel_size[1]}` 是卷积核的高度和宽度。完整卷积核的shape为 :math:`(C_{out}, C_{in} / \text{group}, \text{kernel_size[0]}, \text{kernel_size[1]})` ,其中 `group` 是在通道上分割输入 `x` 的组数。
|
||||
|
||||
如果 `pad_mode` 设置为"valid",则输出高度和宽度将分别为 :math:`\left \lfloor{1 + \frac{H_{in} + \text{padding[0]} + \text{padding[1]} - \text{kernel_size[0]} - (\text{kernel_size[0]} - 1) \times (\text{dilation[0]} - 1) }{\text{stride[0]}}} \right \rfloor` 和 :math:`\left \lfloor{1 + \frac{W_{in} + \text{padding[2]} + \text{padding[3]} - \text{kernel_size[1]} - (\text{kernel_size[1]} - 1) \times (\text{dilation[1]} - 1) }{\text{stride[1]}}} \right \rfloor` 。
|
||||
如果 `pad_mode` 设置为"pad",则输出高度和宽度将分别为 :math:`\left \lfloor{1 + \frac{H_{in} + \text{padding[0]} + \text{padding[1]} - \text{kernel_size[0]} - (\text{kernel_size[0]} - 1) \times (\text{dilation[0]} - 1) }{\text{stride[0]}}} \right \rfloor` 和 :math:`\left \lfloor{1 + \frac{W_{in} + \text{padding[2]} + \text{padding[3]} - \text{kernel_size[1]} - (\text{kernel_size[1]} - 1) \times (\text{dilation[1]} - 1) }{\text{stride[1]}}} \right \rfloor` 。
|
||||
其中, :math:`dialtion` 为卷积核元素之间的间距, :math:`stride` 为移动步长, :math:`padding` 为添加到输入两侧的零填充。
|
||||
|
||||
请参考论文 `Gradient Based Learning Applied to Document Recognition <http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf>`_ 。更详细的介绍,参见:http://cs231n.github.io/convolutional-networks/。
|
||||
|
|
|
@ -195,28 +195,28 @@ class Conv2d(_Conv):
|
|||
|
||||
.. math::
|
||||
\begin{array}{ll} \\
|
||||
H_{out} = \left \lfloor{\frac{H_{in}}{\text{stride[0]}} + 1} \right \rfloor \\
|
||||
W_{out} = \left \lfloor{\frac{W_{in}}{\text{stride[1]}} + 1} \right \rfloor \\
|
||||
H_{out} = \left \lceil{\frac{H_{in}}{\text{stride[0]}}} \right \rceil \\
|
||||
W_{out} = \left \lceil{\frac{W_{in}}{\text{stride[1]}}} \right \rceil \\
|
||||
\end{array}
|
||||
|
||||
pad_mode is 'valid':
|
||||
|
||||
.. math::
|
||||
\begin{array}{ll} \\
|
||||
H_{out} = \left \lfloor{\frac{H_{in} - \text{dilation[0]} \times (\text{kernel_size[0]} - 1) }
|
||||
{\text{stride[0]}} + 1} \right \rfloor \\
|
||||
W_{out} = \left \lfloor{\frac{W_{in} - \text{dilation[1]} \times (\text{kernel_size[1]} - 1) }
|
||||
{\text{stride[1]}} + 1} \right \rfloor \\
|
||||
H_{out} = \left \lceil{\frac{H_{in} - \text{dilation[0]} \times (\text{kernel_size[0]} - 1) }
|
||||
{\text{stride[0]}}} \right \rceil \\
|
||||
W_{out} = \left \lceil{\frac{W_{in} - \text{dilation[1]} \times (\text{kernel_size[1]} - 1) }
|
||||
{\text{stride[1]}}} \right \rceil \\
|
||||
\end{array}
|
||||
|
||||
pad_mode is 'pad':
|
||||
|
||||
.. math::
|
||||
\begin{array}{ll} \\
|
||||
H_{out} = \left \lfloor{\frac{H_{in} + padding[0] + padding[1] - (\text{dilation[0]} - 1) \times
|
||||
\text{kernel_size[0]} - 1 }{\text{stride[0]}} + 1} \right \rfloor \\
|
||||
W_{out} = \left \lfloor{\frac{W_{in} + padding[2] + padding[3] - (\text{dilation[1]} - 1) \times
|
||||
\text{kernel_size[1]} - 1 }{\text{stride[1]}} + 1} \right \rfloor \\
|
||||
H_{out} = \left \lfloor{\frac{H_{in} + padding[0] + padding[1] - (\text{kernel_size[0]} - 1) \times
|
||||
\text{dilation[0]} - 1 }{\text{stride[0]}} + 1} \right \rfloor \\
|
||||
W_{out} = \left \lfloor{\frac{W_{in} + padding[2] + padding[3] - (\text{kernel_size[1]} - 1) \times
|
||||
\text{dilation[1]} - 1 }{\text{stride[1]}} + 1} \right \rfloor \\
|
||||
\end{array}
|
||||
|
||||
Raises:
|
||||
|
@ -1223,19 +1223,19 @@ class Conv1dTranspose(_Conv):
|
|||
pad_mode is 'same':
|
||||
|
||||
.. math::
|
||||
L_{out} = \left \lfloor{\frac{L_{in}}{\text{stride}} + 1} \right \rfloor
|
||||
L_{out} = \left \lceil{\frac{L_{in}}{\text{stride}}} \right \rceil
|
||||
|
||||
pad_mode is 'valid':
|
||||
|
||||
.. math::
|
||||
L_{out} = \left \lfloor{\frac{L_{in} - \text{dilation} \times (\text{kernel_size} - 1) }
|
||||
{\text{stride}} + 1} \right \rfloor
|
||||
L_{out} = \left \lceil{\frac{L_{in} - \text{dilation} \times (\text{kernel_size} - 1) }
|
||||
{\text{stride}}} \right \rceil
|
||||
|
||||
pad_mode is 'pad':
|
||||
|
||||
.. math::
|
||||
L_{out} = \left \lfloor{\frac{L_{in} + 2 \times padding - (\text{dilation} - 1) \times
|
||||
\text{kernel_size} - 1 }{\text{stride}} + 1} \right \rfloor
|
||||
L_{out} = \left \lfloor{\frac{L_{in} + 2 \times padding - (\text{kernel_size} - 1) \times
|
||||
\text{dilation} - 1 }{\text{stride}} + 1} \right \rfloor
|
||||
|
||||
Raises:
|
||||
TypeError: If `in_channels`, `out_channels`, `kernel_size`, `stride`, `padding` or `dilation` is not an int.
|
||||
|
|
|
@ -1280,7 +1280,7 @@ class Conv2D(Primitive):
|
|||
:math:`(C_{out}, C_{in} / \text{group}, \text{kernel_size[0]}, \text{kernel_size[1]})`,
|
||||
where group is the group number to split the input in the channel dimension.
|
||||
|
||||
If the 'pad_mode' is set to be "valid", the output height and width will be
|
||||
If the 'pad_mode' is set to be "pad", the output height and width will be
|
||||
:math:`\left \lfloor{1 + \frac{H_{in} + \text{padding[0]} + \text{padding[1]} - \text{kernel_size[0]} -
|
||||
(\text{kernel_size[0]} - 1) \times (\text{dilation[0]} - 1) }{\text{stride[0]}}} \right \rfloor` and
|
||||
:math:`\left \lfloor{1 + \frac{W_{in} + \text{padding[2]} + \text{padding[3]} - \text{kernel_size[1]} -
|
||||
|
|
Loading…
Reference in New Issue