From a8e43b125a352aedee5438a5ea3daa4c5930a1c6 Mon Sep 17 00:00:00 2001 From: chenkang Date: Tue, 7 Mar 2023 14:48:59 +0800 Subject: [PATCH] fix conv2dtranspose doc --- .../api_python/nn/mindspore.nn.Conv2dTranspose.rst | 2 +- mindspore/python/mindspore/nn/layer/conv.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/api/api_python/nn/mindspore.nn.Conv2dTranspose.rst b/docs/api/api_python/nn/mindspore.nn.Conv2dTranspose.rst index 0f9d539130f..9c0803ce770 100644 --- a/docs/api/api_python/nn/mindspore.nn.Conv2dTranspose.rst +++ b/docs/api/api_python/nn/mindspore.nn.Conv2dTranspose.rst @@ -21,7 +21,7 @@ mindspore.nn.Conv2dTranspose - **pad**:对输入进行填充。在输入的高度和宽度方向上填充 `padding` 大小的0。如果设置此模式, `padding` 必须大于或等于0。 - **padding** (Union[int, tuple[int]]) - 输入的高度和宽度方向上填充的数量。数据类型为整型或包含四个整数的tuple。如果 `padding` 是一个整数,那么上、下、左、右的填充都等于 `padding` 。如果 `padding` 是一个有四个整数的tuple,那么上、下、左、右的填充分别等于 `padding[0]` 、 `padding[1]` 、 `padding[2]` 和 `padding[3]` 。值应该要大于等于0,默认值:0。 - - **output_padding** (Union[int, tuple[int]]) - 输入的高度和宽度方向上填充的数量。数据类型为整型或包含两个整数的tuple。如果 `output_padding` 是一个整数,那么下、右的填充都等于 `output_padding` 。如果 `output_padding` 是一个有两个整数的tuple,那么下、右的填充分别等于 `output_padding[0]` 、 `output_padding[1]` 。值应该要大于等于0,默认值:0。 + - **output_padding** (Union[int, tuple[int]]) - 输出的高度和宽度方向上填充的数量。数据类型为整型或包含两个整数的tuple。如果 `output_padding` 是一个整数,那么下、右的填充都等于 `output_padding` 。如果 `output_padding` 是一个有两个整数的tuple,那么下、右的填充分别等于 `output_padding[0]` 、 `output_padding[1]` 。如果 `output_padding` 不为0, `pad_mode` 必须为 `pad` 。 `output_padding` 取值范围为 `[0, max(stride, dilation))` ,默认值:0。 - **dilation** (Union[int, tuple[int]]) - 二维卷积核膨胀尺寸。数据类型为整型或具有两个整型的tuple。若 :math:`k > 1` ,则kernel间隔 `k` 个元素进行采样。高度和宽度方向上的 `k` ,其取值范围分别为[1, H]和[1, W]。默认值:1。 - **group** (int) - 将过滤器拆分为组, `in_channels` 和 `out_channels` 必须可被 `group` 整除。如果组数等于 `in_channels` 和 `out_channels` ,这个二维卷积层也被称为二维深度卷积层。默认值:1. - **has_bias** (bool) - Conv2dTranspose层是否添加偏置参数。默认值:False。 diff --git a/mindspore/python/mindspore/nn/layer/conv.py b/mindspore/python/mindspore/nn/layer/conv.py index 3dffc1d7bf4..fbe5c1c92a2 100644 --- a/mindspore/python/mindspore/nn/layer/conv.py +++ b/mindspore/python/mindspore/nn/layer/conv.py @@ -968,7 +968,8 @@ class Conv2dTranspose(_Conv): The data type is an integer or a tuple of two integers. If `output_padding` is an integer, then the bottom and right padding are all equal to `output_padding`. If `output_padding` is a tuple of 2 integers, then the bottom and right padding is equal to `output_padding[0]`, `output_padding[1]` - respectively. The value should be greater than or equal to 0. Default: 0. + respectively. If `output_padding` is not equal to 0, `pad_mode` must be `pad`. + The value should be in range of `[0, max(stride, dilation))` . Default: 0. dilation (Union[int, tuple[int]]): Dilation size of 2D convolution kernel. The data type is an integer or a tuple of two integers. If :math:`k > 1`, the kernel is sampled every `k` elements. The value of `k` on the height and width directions is in range of [1, H] @@ -1124,9 +1125,9 @@ class Conv2dTranspose(_Conv): conv2d_trans_ret = self.conv2d_transpose(x, self.weight, (n, self.out_channels, h_out, w_out)) if isinstance(self.output_padding, tuple): if self.output_padding[0] < 0 or self.output_padding[0] >= max(self.dilation[0], self.stride[0]): - raise ValueError("output_padding[0] must be in range of [0, max(stride_d, dilation_d)).") + raise ValueError("output_padding[0] must be in range of [0, max(stride_h, dilation_h)).") if self.output_padding[1] < 0 or self.output_padding[1] >= max(self.dilation[1], self.stride[1]): - raise ValueError("output_padding[1] must be in range of [0, max(stride_d, dilation_d)).") + raise ValueError("output_padding[1] must be in range of [0, max(stride_w, dilation_w)).") if not self.is_pad and (self.output_padding[0] > 0 or self.output_padding[1] > 0): raise ValueError("when output_padding is not zero, pad_mode must be 'pad'") @@ -1137,9 +1138,9 @@ class Conv2dTranspose(_Conv): return conv2d_trans_ret if self.output_padding < 0 or self.output_padding >= max(self.dilation[0], self.stride[0]): - raise ValueError("output_padding must be in range of [0, max(stride_d, dilation_d)).") + raise ValueError("output_padding must be in range of [0, max(stride_h, dilation_h)).") if self.output_padding < 0 or self.output_padding >= max(self.dilation[1], self.stride[1]): - raise ValueError("output_padding must be in range of [0, max(stride_d, dilation_d)).") + raise ValueError("output_padding must be in range of [0, max(stride_w, dilation_w)).") if not self.is_pad and self.output_padding > 0: raise ValueError("when output_padding is not zero, pad_mode must be 'pad'") pad = P.Pad(paddings=((0, 0), (0, 0), (0, self.output_padding), (0, self.output_padding)))