forked from mindspore-Ecosystem/mindspore
!44986 fix rot docs and roll
Merge pull request !44986 from 冯一航/fix_roll_and_rot_docs
This commit is contained in:
commit
af9bf8fe71
|
@ -3,7 +3,7 @@ mindspore.Tensor.rot90
|
|||
|
||||
.. py:method:: mindspore.Tensor.rot90(k, dims)
|
||||
|
||||
沿轴指定的平面内将n-D张量旋转90度。
|
||||
沿轴指定的平面内将n-D Tensor旋转90度。
|
||||
如果 `k>0`,旋转方向是从第一轴朝向第二轴,如果 `k<0`,旋转方向从第二轴朝向第一轴。
|
||||
|
||||
参数:
|
||||
|
|
|
@ -33,5 +33,6 @@ mindspore.nn.LPPool1d
|
|||
- **TypeError** - `kernel_size` 或 `stride` 不是int。
|
||||
- **TypeError** - `ceil_mode` 不是bool。
|
||||
- **TypeError** - `norm_type` 不是float也不是int。
|
||||
- **ValueError** - `norm_type` 等于0。
|
||||
- **ValueError** - `kernel_size` 或 `stride` 小于1。
|
||||
- **ValueError** - `x` 的shape长度不等于2或3。
|
|
@ -33,6 +33,7 @@ mindspore.nn.LPPool2d
|
|||
- **TypeError** - `kernel_size` 或 `stride` 不是int也不是tuple。
|
||||
- **TypeError** - `ceil_mode` 不是bool。
|
||||
- **TypeError** - `norm_type` 不是float也不是int。
|
||||
- **ValueError** - `norm_type` 等于0。
|
||||
- **ValueError** - `kernel_size` 或 `stride` 小于1。
|
||||
- **ValueError** - `kernel_size` 或 `stride` 是一个长度不为2的tuple。
|
||||
- **ValueError** - `x` 的shape长度不等于4。
|
|
@ -31,5 +31,6 @@ mindspore.ops.lp_pool1d
|
|||
- **TypeError** - `kernel_size` 或 `stride` 不是int。
|
||||
- **TypeError** - `ceil_mode` 不是bool。
|
||||
- **TypeError** - `norm_type` 不是float也不是int。
|
||||
- **ValueError** - `norm_type` 等于0。
|
||||
- **ValueError** - `kernel_size` 或 `stride` 小于1。
|
||||
- **ValueError** - `x` 的shape长度不等于2或3。
|
|
@ -31,6 +31,7 @@ mindspore.ops.lp_pool2d
|
|||
- **TypeError** - `kernel_size` 或 `stride` 不是int也不是tuple。
|
||||
- **TypeError** - `ceil_mode` 不是bool。
|
||||
- **TypeError** - `norm_type` 不是float也不是int。
|
||||
- **ValueError** - `norm_type` 等于0。
|
||||
- **ValueError** - `kernel_size` 或 `stride` 小于1。
|
||||
- **ValueError** - `kernel_size` 或 `stride` 是一个长度不为2的tuple。
|
||||
- **ValueError** - `x` 的shape长度不等于4。
|
|
@ -116,6 +116,7 @@ class LPPool1d(Cell):
|
|||
TypeError: If `kernel_size` or `stride` is not an int.
|
||||
TypeError: If `ceil_mode` is not a bool.
|
||||
TypeError: If `norm_type` is neither float nor int.
|
||||
ValueError: If `norm_type` is equal to 0.
|
||||
ValueError: If `kernel_size` or `stride` is less than 1.
|
||||
ValueError: If length of shape of `x` is not equal to 2 or 3.
|
||||
|
||||
|
@ -190,6 +191,7 @@ class LPPool2d(Cell):
|
|||
TypeError: If `kernel_size` or `stride` is neither int nor tuple.
|
||||
TypeError: If `ceil_mode` is not a bool.
|
||||
TypeError: If `norm_type` is neither float nor int.
|
||||
ValueError: If `norm_type` is equal to 0.
|
||||
ValueError: If `kernel_size` or `stride` is less than 1.
|
||||
ValueError: If `kernel_size` or `stride` is a tuple whose length is not equal to `2`.
|
||||
ValueError: If length of shape of `x` is not equal to 4.
|
||||
|
|
|
@ -5678,7 +5678,7 @@ def rot90(x, k, dims):
|
|||
return out
|
||||
|
||||
|
||||
def roll(x, shifts, dims):
|
||||
def roll(x, shifts, dims=None):
|
||||
"""
|
||||
Rolls the elements of a tensor along an axis.
|
||||
|
||||
|
@ -5709,6 +5709,7 @@ def roll(x, shifts, dims):
|
|||
>>> print(output)
|
||||
[3. 4. 0. 1. 2.]
|
||||
"""
|
||||
dims = dims if dims is not None else 0
|
||||
return Roll(shifts, dims)(x)
|
||||
|
||||
|
||||
|
|
|
@ -4073,6 +4073,7 @@ def lp_pool1d(x, norm_type, kernel_size, stride=None, ceil_mode=False):
|
|||
TypeError: If `kernel_size` or `stride` is not an int.
|
||||
TypeError: If `ceil_mode` is not a bool.
|
||||
TypeError: If `norm_type` is neither float nor int.
|
||||
ValueError: If `norm_type` is equal to 0.
|
||||
ValueError: If `kernel_size` or `stride` is less than 1.
|
||||
ValueError: If length of shape of `x` is not equal to 2 or 3.
|
||||
|
||||
|
@ -4099,6 +4100,8 @@ def lp_pool1d(x, norm_type, kernel_size, stride=None, ceil_mode=False):
|
|||
norm_type = float(norm_type)
|
||||
else:
|
||||
raise TypeError(f"For lp_pool1d, the type of 'norm_type' must be float or int, but got {type(norm_type)}")
|
||||
if norm_type == 0:
|
||||
raise ValueError(f"For lp_pool1d, the value of 'norm_type' can not be 0.")
|
||||
sign = _get_cache_prim(ops.Sign)()
|
||||
squeeze = _get_cache_prim(ops.Squeeze)(0)
|
||||
expand_dims = _get_cache_prim(ops.ExpandDims)()
|
||||
|
@ -4153,6 +4156,7 @@ def lp_pool2d(x, norm_type, kernel_size, stride=None, ceil_mode=False):
|
|||
TypeError: If `kernel_size` or `stride` is neither int nor tuple.
|
||||
TypeError: If `ceil_mode` is not a bool.
|
||||
TypeError: If `norm_type` is neither float nor int.
|
||||
ValueError: If `norm_type` is equal to 0.
|
||||
ValueError: If `kernel_size` or `stride` is less than 1.
|
||||
ValueError: If `kernel_size` or `stride` is a tuple whose length is not equal to `2`.
|
||||
ValueError: If length of shape of `x` is not equal to 4.
|
||||
|
@ -4187,6 +4191,8 @@ def lp_pool2d(x, norm_type, kernel_size, stride=None, ceil_mode=False):
|
|||
norm_type = float(norm_type)
|
||||
else:
|
||||
raise TypeError(f"For lp_pool2d, the type of 'norm_type' must be float or int, but got {type(norm_type)}")
|
||||
if norm_type == 0:
|
||||
raise ValueError(f"For lp_pool2d, the value of 'norm_type' can not be 0.")
|
||||
sign = _get_cache_prim(ops.Sign)()
|
||||
if not isinstance(x, tuple):
|
||||
kernel_size = tuple((kernel_size, kernel_size))
|
||||
|
|
Loading…
Reference in New Issue