diff --git a/docs/api/api_python/nn/mindspore.nn.AdaptiveAvgPool1d.rst b/docs/api/api_python/nn/mindspore.nn.AdaptiveAvgPool1d.rst index c288b45cb07..997b4b96e08 100644 --- a/docs/api/api_python/nn/mindspore.nn.AdaptiveAvgPool1d.rst +++ b/docs/api/api_python/nn/mindspore.nn.AdaptiveAvgPool1d.rst @@ -17,7 +17,7 @@ mindspore.nn.AdaptiveAvgPool1d **输入:** - - **x** (Tensor) - shape为 :math:`(N, C_{in}, L_{in})` 的Tensor,数据类型为float16,float32或float64。 + - **x** (Tensor) - shape为 :math:`(N, C_{in}, L_{in})` 的Tensor,数据类型为float16或float32。 **输出:** @@ -26,7 +26,7 @@ mindspore.nn.AdaptiveAvgPool1d **异常:** - **TypeError** - `output_size` 不是int。 - - **TypeError** - `x` 不是float16或float32或float64。 + - **TypeError** - `x` 不是float16或float32。 - **ValueError** - `output_size` 小于1。 - **ValueError** - `x` 的shape长度不等于3。 - **ValueError** - `x` 的最后一个维度小于 `output_size`。 diff --git a/docs/api/api_python/nn/mindspore.nn.AdaptiveMaxPool1d.rst b/docs/api/api_python/nn/mindspore.nn.AdaptiveMaxPool1d.rst index d15731220e5..30e2c78bbbb 100644 --- a/docs/api/api_python/nn/mindspore.nn.AdaptiveMaxPool1d.rst +++ b/docs/api/api_python/nn/mindspore.nn.AdaptiveMaxPool1d.rst @@ -17,7 +17,7 @@ mindspore.nn.AdaptiveMaxPool1d **输入:** - - **x** (Tensor) - shape为 :math:`(N, C_{in}, L_{in})` 的Tensor,数据类型为float16,float32或float64。 + - **x** (Tensor) - shape为 :math:`(N, C_{in}, L_{in})` 的Tensor,数据类型为float16或float32。 **输出:** @@ -25,7 +25,7 @@ mindspore.nn.AdaptiveMaxPool1d **异常:** - - **TypeError** - `x` 不是float16或float32或float64。 + - **TypeError** - `x` 不是float16或float32。 - **TypeError** - `output_size` 不是int。 - **ValueError** - `output_size` 小于1。 - **ValueError** - `x` 的最后一个维度小于 `output_size`。 diff --git a/mindspore/python/mindspore/nn/layer/pooling.py b/mindspore/python/mindspore/nn/layer/pooling.py index 6bd1b5b3053..1b83d7e00cc 100644 --- a/mindspore/python/mindspore/nn/layer/pooling.py +++ b/mindspore/python/mindspore/nn/layer/pooling.py @@ -421,8 +421,8 @@ def _adaptive_shape_check(in_shape, output_size, prim_name): @constexpr def _adaptive_dtype_check(x_dtype, prim_name): """Check dtype.""" - if x_dtype not in [mstype.float16, mstype.float32, mstype.float64]: - raise TypeError("For {}, the x_dtype must be float16, float32 or float64, " + if x_dtype not in [mstype.float16, mstype.float32]: + raise TypeError("For {}, the x_dtype must be float16 or float32, " "but got {}.".format(prim_name, x_dtype)) @@ -445,14 +445,14 @@ class AdaptiveAvgPool1d(Cell): output_size (int): the target output size :math:`L_{out}`. Inputs: - - **x** (Tensor) - Tensor of shape :math:`(N, C_{in}, L_{in})`, with float16, float32 or float64 data type. + - **x** (Tensor) - Tensor of shape :math:`(N, C_{in}, L_{in})`, with float16 or float32 data type. Outputs: Tensor of shape :math:`(N, C_{in}, L_{out})`, has the same type as `x`. Raises: TypeError: If `output_size` is not an int. - TypeError: If `x` is neither float16 nor float32 nor float64. + TypeError: If `x` is neither float16 nor float32. ValueError: If `output_size` is less than 1. ValueError: If length of shape of `x` is not equal to 3. ValueError: If the last dimension of `x` is smaller than `output_size`. @@ -463,6 +463,9 @@ class AdaptiveAvgPool1d(Cell): ``Ascend`` ``GPU`` ``CPU`` Examples: + >>> import mindspore + >>> from mindspore import Tensor, nn + >>> import numpy as np >>> pool = nn.AdaptiveAvgPool1d(output_size=2) >>> x = Tensor(np.random.randint(0, 10, [1, 3, 6]), mindspore.float32) >>> output = pool(x) @@ -519,13 +522,13 @@ class AdaptiveMaxPool1d(Cell): output_size (int): the target output size :math:`L_{out}`. Inputs: - - **x** (Tensor) - Tensor of shape :math:`(N, C_{in}, L_{in})`, with float16, float32 or float64 data type. + - **x** (Tensor) - Tensor of shape :math:`(N, C_{in}, L_{in})`, with float16 or float32 data type. Outputs: Tensor of shape :math:`(N, C_{in}, L_{out})`, has the same type as `x`. Raises: - TypeError: If `x` is neither float16 nor float32 nor float64. + TypeError: If `x` is neither float16 nor float32. TypeError: If `output_size` is not an int. ValueError: If `output_size` is less than 1. ValueError: If the last dimension of `x` is smaller than `output_size`. @@ -537,6 +540,9 @@ class AdaptiveMaxPool1d(Cell): ``Ascend`` ``GPU`` ``CPU`` Examples: + >>> import mindspore + >>> from mindspore import Tensor, nn + >>> import numpy as np >>> pool = nn.AdaptiveMaxPool1d(output_size=3) >>> x = Tensor(np.random.randint(0, 10, [1, 3, 6]), mindspore.float32) >>> output = pool(x)