forked from mindspore-Ecosystem/mindspore
fix some issues
This commit is contained in:
parent
7b1d48bded
commit
05b1899052
|
@ -570,6 +570,7 @@ Array操作
|
|||
mindspore.ops.Sort
|
||||
mindspore.ops.SpaceToBatchND
|
||||
mindspore.ops.SpaceToDepth
|
||||
mindspore.ops.SparseSlice
|
||||
mindspore.ops.SparseGatherV2
|
||||
mindspore.ops.Split
|
||||
mindspore.ops.SplitV
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
- **data_format** (str,可选) - 数据格式的值。目前只支持 `NCHW` ,默认值: `NCHW` 。
|
||||
|
||||
输入:
|
||||
- **x** (Tensor) - 输入数据。一个四维Tensor,数据类型为float16、float32,shape必须为
|
||||
- **x** (Tensor) - 输入数据。一个四维Tensor,shape必须为
|
||||
:math:`(N, C_{in}, H_{in}, W_{in})` 。
|
||||
- **filter** (Tensor) - 一个三维Tensor,数据类型和输入 `x` 相同,shape必须为
|
||||
:math:`(C_{in}, H_{filter}, W_{filter})` 。
|
||||
|
|
|
@ -3,32 +3,4 @@ mindspore.ops.ResizeBilinear
|
|||
|
||||
.. py:class:: mindspore.ops.ResizeBilinear(size, align_corners=False, half_pixel_centers=False)
|
||||
|
||||
使用双线性插值调整图像大小到指定的大小。
|
||||
|
||||
调整输入图像的高和宽。且可以输入不同数据类型的图像,但输出的数据类型只能是float32。
|
||||
|
||||
使用通用resize功能请参考 :func:`mindspore.ops.interpolate`。
|
||||
|
||||
.. warning::
|
||||
这个接口不支持动态shape,而且将来可能面临更改或删除,用 :func:`mindspore.ops.interpolate` 可替代该接口。
|
||||
|
||||
参数:
|
||||
- **size** (Union[tuple[int], list[int]]) - 指定图像的新尺寸,输入格式为:2个int元素 :math:`(new\_height, new\_width)` 的tuple或者list。
|
||||
- **align_corners** (bool) - 如果为True,则通过 :math:`(new\_height - 1) / (height - 1)` 调整输入,这将精确对齐图像的4个角和调整图像大小。如果为False,则按 :math:`new\_height / height` 调整输入。默认值:False。
|
||||
- **half_pixel_centers** (bool) - 是否几何中心对齐。如果设置为True, 那么 `scale_factor` 应该设置为False。默认值:False。
|
||||
|
||||
输入:
|
||||
- **x** (Tensor) - ResizeBilinear的输入,四维的Tensor,其shape为 :math:`(batch, channels, height, width)` ,数据类型为float32或float16。
|
||||
|
||||
输出:
|
||||
Tensor,调整大小后的图像。shape为 :math:`(batch, channels, new\_height, new\_width)` 的四维Tensor,数据类型与输入 `x` 相同。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `size` 既不是tuple,也不是list。
|
||||
- **TypeError** - `align_corners` 不是bool。
|
||||
- **TypeError** - `half_pixel_centers` 不是bool。
|
||||
- **TypeError** - `align_corners` 和 `half_pixel_centers` 都为True。
|
||||
- **TypeError** - `half_pixel_centers` 为True,且device_target不为Ascend。
|
||||
- **TypeError** - `x` 的数据类型既不是float16也不是float32。
|
||||
- **TypeError** - `x` 不是Tensor。
|
||||
- **ValueError** - `x` 的shape长度不等于4。
|
||||
此接口已弃用,请使用 :class:`mindspore.ops.ResizeBilinearV2` 。如果要使用其他插值方法进行尺寸调整,请参考 :func:`mindspore.ops.interpolate` 。
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
mindspore.ops.SparseSlice
|
||||
==========================
|
||||
|
||||
.. py:class:: mindspore.ops.SparseSlice
|
||||
|
||||
基于 `start` 和 `size` 对稀疏Tensor进行切片。
|
||||
|
||||
输入:
|
||||
- **indices** (Tensor) - 稀疏Tensor的索引,是一个二维Tensor(N乘R的矩阵),shape为 :math:`(N, R)` 。支持的数据类型为int64,其每一个值都必须是非负整数。
|
||||
- **values** (Tensor)- 稀疏Tensor `indices` 对应位置的值,是一个一维Tensor,shape为 :math:`(N,)` 。
|
||||
- **shape** (Tensor) - 稀疏Tensor的shape,是一个一维Tensor,shape为 :math:`(R,)` ,数据类型为int64。
|
||||
- **start** (Tensor) - 切片操作起始位置,是一个一维Tensor,shape为 :math:`(R,)` ,数据类型为int64。
|
||||
- **size** (Tensor) - 切片的尺寸,是一个一维Tensor,shape为 :math:`(R,)` ,数据类型为int64。
|
||||
|
||||
输出:
|
||||
切片操作生成一个 `SparseTensor` 对象。
|
||||
|
||||
- y_indices: int64类型的Tensor。
|
||||
- y_values: 数据类型与 `values` 相同的Tensor.
|
||||
- y_shape: int64类型的Tensor,其大小与 `size` 相同。
|
||||
|
||||
异常:
|
||||
- **TypeError** - `indices`、 `shape`、 `start` 和 `size` 不是int64数据类型。
|
||||
- **ValueError** - `indices` 不是2维Tensor。
|
||||
- **ValueError** - `values`、 `start`、 `shape` 和 `size` 不是一维Tensor。
|
||||
- **ValueError** - `indices` 和 `values` 对应元素数量不一致。
|
||||
- **ValueError** - `indices[1]` 与 `shape` 的shape不一致。
|
||||
- **ValueError** - `shape` 与 `start` 的shape不一致。
|
||||
- **ValueError** - `shape` 与 `size` git的shape不一致。
|
|
@ -569,6 +569,7 @@ Array Operation
|
|||
mindspore.ops.Sort
|
||||
mindspore.ops.SpaceToBatchND
|
||||
mindspore.ops.SpaceToDepth
|
||||
mindspore.ops.SparseSlice
|
||||
mindspore.ops.SparseGatherV2
|
||||
mindspore.ops.Split
|
||||
mindspore.ops.SplitV
|
||||
|
|
|
@ -9854,6 +9854,7 @@ __all__ = [
|
|||
'imag',
|
||||
'roll',
|
||||
'sum',
|
||||
'matrix_exp'
|
||||
'matrix_exp',
|
||||
'orgqr'
|
||||
]
|
||||
__all__.sort()
|
||||
|
|
|
@ -123,7 +123,7 @@ from .random_ops import (RandomChoiceWithMask, StandardNormal, Gamma, RandomGamm
|
|||
LogUniformCandidateSampler, TruncatedNormal, LogNormalReverse, NonDeterministicInts,
|
||||
ParameterizedTruncatedNormal, RandomPoisson)
|
||||
from .rl_ops import (BufferAppend, BufferGetItem, BufferSample)
|
||||
from .sparse_ops import (SparseToDense, SparseTensorDenseMatmul, SparseTensorDenseAdd)
|
||||
from .sparse_ops import (SparseToDense, SparseTensorDenseMatmul, SparseTensorDenseAdd, SparseSlice)
|
||||
from .spectral_ops import (BartlettWindow, BlackmanWindow)
|
||||
|
||||
__all__ = [
|
||||
|
@ -643,7 +643,8 @@ __all__ = [
|
|||
"Zeta",
|
||||
"PadV3",
|
||||
"Roll",
|
||||
"Lgamma"
|
||||
"Lgamma",
|
||||
"SparseSlice"
|
||||
]
|
||||
|
||||
__custom__ = [
|
||||
|
|
|
@ -3623,57 +3623,11 @@ class DropoutDoMask(Primitive):
|
|||
|
||||
class ResizeBilinear(PrimitiveWithInfer):
|
||||
r"""
|
||||
Resizes an image to a certain size using the bilinear interpolation.
|
||||
|
||||
The resizing only affects the lower two dimensions which represent the height and width. The input images
|
||||
can be represented by different data types, but the data types of output images are always float32.
|
||||
|
||||
For general resize, refer to :func:`mindspore.ops.interpolate` for more details.
|
||||
|
||||
.. warning::
|
||||
This interface does not support dynamic shape and is subject to change or deletion,
|
||||
use :func:`mindspore.ops.interpolate` instead.
|
||||
|
||||
Args:
|
||||
size (Union[tuple[int], list[int]]): A tuple or list of 2 int elements :math:`(new\_height, new\_width)`,
|
||||
the new size of the images.
|
||||
align_corners (bool): If true, rescale input by :math:`(new\_height - 1) / (height - 1)`,
|
||||
which exactly aligns the 4 corners of images and resized images. If false,
|
||||
rescale by :math:`new\_height / height`. Default: False.
|
||||
half_pixel_centers (bool): Whether half pixel center. If set to True, `align_corners` should be False.
|
||||
Default: False.
|
||||
|
||||
Inputs:
|
||||
- **x** (Tensor) - Image to be resized. Input images must be a 4-D tensor with shape
|
||||
:math:`(batch, channels, height, width)`, with data type of float32 or float16.
|
||||
|
||||
Outputs:
|
||||
Tensor, resized image. 4-D with shape :math:`(batch, channels, new\_height, new\_width)`,
|
||||
with the same data type as input `x`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `size` is neither a tuple nor list.
|
||||
TypeError: If `align_corners` is not a bool.
|
||||
TypeError: If `half_pixel_centers` is not a bool.
|
||||
TypeError: If `align_corners` and `half_pixel_centers` are all True.
|
||||
TypeError: If `half_pixel_centers` is True and device_target not Ascend.
|
||||
TypeError: If dtype of `x` is neither float16 nor float32.
|
||||
TypeError: If `x` is not a Tensor.
|
||||
ValueError: If length of shape of `x` is not equal to 4.
|
||||
This API is deprecated, please use the :class:`mindspore.ops.ResizeBilinearV2` instead.
|
||||
For general resizing with other interpolation methods, refer to :func:`mindspore.ops.interpolate` for more details.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
Examples:
|
||||
>>> x = Tensor([[[[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]]], mindspore.float32)
|
||||
>>> resize_bilinear = ops.ResizeBilinear((5, 5))
|
||||
>>> output = resize_bilinear(x)
|
||||
>>> print(output)
|
||||
[[[[1. 2. 3. 4. 5.]
|
||||
[1. 2. 3. 4. 5.]
|
||||
[1. 2. 3. 4. 5.]
|
||||
[1. 2. 3. 4. 5.]
|
||||
[1. 2. 3. 4. 5.]]]]
|
||||
Deprecated
|
||||
"""
|
||||
|
||||
@prim_attr_register
|
||||
|
@ -7096,7 +7050,7 @@ class CTCGreedyDecoder(Primitive):
|
|||
|
||||
Examples:
|
||||
>>> inputs = Tensor(np.array([[[0.6, 0.4, 0.2], [0.8, 0.6, 0.3]],
|
||||
>>> [[0.0, 0.6, 0.0], [0.5, 0.4, 0.5]]]), mindspore.float32)
|
||||
... [[0.0, 0.6, 0.0], [0.5, 0.4, 0.5]]]), mindspore.float32)
|
||||
>>> sequence_length = Tensor(np.array([2, 2]), mindspore.int32)
|
||||
>>> decoded_indices, decoded_values, decoded_shape, log_probability = ops.CTCGreedyDecoder()(inputs,
|
||||
... sequence_length)
|
||||
|
@ -7972,7 +7926,7 @@ class CTCLossV2(Primitive):
|
|||
|
||||
Examples:
|
||||
>>> log_probs = Tensor(np.array([[[0.3, 0.6, 0.6]],
|
||||
[[0.9, 0.4, 0.2]]]).astype(np.float32))
|
||||
... [[0.9, 0.4, 0.2]]]).astype(np.float32))
|
||||
>>> targets = Tensor(np.array([[0, 1]]), mstype.int32)
|
||||
>>> input_lengths = Tensor(np.array([2]), mstype.int32)
|
||||
>>> target_lengths = Tensor(np.array([1]), mstype.int32)
|
||||
|
@ -8271,7 +8225,7 @@ class Dilation2D(Primitive):
|
|||
data_format (str, optional): The value for data format, only 'NCHW' is supported at present. Default: "NCHW".
|
||||
|
||||
Inputs:
|
||||
- **x** (Tensor) - Input data. A four dimension tensor with float16 or float32 data type. The shape must be
|
||||
- **x** (Tensor) - Input data. A 4-D Tensor, its shape must be
|
||||
:math:`(N, C_{in}, H_{in}, W_{in})`.
|
||||
- **filter** (Tensor) - A three dimension tensor with the same type as input. The shape must be
|
||||
:math:`(C_{in}, H_{filter}, W_{filter})`.
|
||||
|
|
|
@ -192,10 +192,10 @@ class SparseDenseCwiseDiv(Primitive):
|
|||
|
||||
class SparseSlice(Primitive):
|
||||
r"""
|
||||
Slices a SparseTensor based on the "start" and "size".
|
||||
Slices a SparseTensor based on the `start` and `size`.
|
||||
|
||||
Inputs:
|
||||
- **indices** (Tensor) - A 2D Tensor (N x R matrix) of type int64. The indices of the SparseTensor.
|
||||
- **indices** (Tensor) - A 2D Tensor (N x R matrix), the indices of the SparseTensor.
|
||||
Support int64, each element value should be a non-negative int number.
|
||||
The shape is :math:`(N, R)`.
|
||||
- **values** (Tensor) - A 1D Tensor, represents the value corresponding to the position in the `indices`.
|
||||
|
@ -210,7 +210,7 @@ class SparseSlice(Primitive):
|
|||
Outputs:
|
||||
A `SparseTensor` objects resulting from splicing.
|
||||
- *y_indices: A Tensor of type int64.
|
||||
- *y_values: A Tensor. Has the same type as "values".
|
||||
- *y_values: A Tensor. Has the same type as `values`.
|
||||
- *y_shape: A Tensor of type int64. Has the same size as `size`.
|
||||
|
||||
Raises:
|
||||
|
|
Loading…
Reference in New Issue