From: @zhunaipan Reviewed-by: @c_34,@stsuteng Signed-off-by: @c_34tags/v1.1.0
| @@ -557,15 +557,15 @@ class Pad(Cell): | |||||
| Tensor, the tensor after padding. | Tensor, the tensor after padding. | ||||
| - If `mode` is "CONSTANT", it fills the edge with 0, regardless of the values of the `input_x`. | - If `mode` is "CONSTANT", it fills the edge with 0, regardless of the values of the `input_x`. | ||||
| If the `input_x` is [[1,2,3],[4,5,6],[7,8,9]] and `paddings` is [[1,1],[2,2]], then the | |||||
| Outputs is [[0,0,0,0,0,0,0],[0,0,1,2,3,0,0],[0,0,4,5,6,0,0],[0,0,7,8,9,0,0],[0,0,0,0,0,0,0]]. | |||||
| If the `input_x` is [[1,2,3], [4,5,6], [7,8,9]] and `paddings` is [[1,1], [2,2]], then the | |||||
| Outputs is [[0,0,0,0,0,0,0], [0,0,1,2,3,0,0], [0,0,4,5,6,0,0], [0,0,7,8,9,0,0], [0,0,0,0,0,0,0]]. | |||||
| - If `mode` is "REFLECT", it uses a way of symmetrical copying throught the axis of symmetry to fill in. | - If `mode` is "REFLECT", it uses a way of symmetrical copying throught the axis of symmetry to fill in. | ||||
| If the `input_x` is [[1,2,3],[4,5,6],[7,8,9]] and `paddings` is [[1,1],[2,2]], then the | |||||
| Outputs is [[6,5,4,5,6,5,4],[3,2,1,2,3,2,1],[6,5,4,5,6,5,4],[9,8,7,8,9,8,7],[6,5,4,5,6,5,4]]. | |||||
| If the `input_x` is [[1,2,3], [4,5,6], [7,8,9]] and `paddings` is [[1,1], [2,2]], then the | |||||
| Outputs is [[6,5,4,5,6,5,4], [3,2,1,2,3,2,1], [6,5,4,5,6,5,4], [9,8,7,8,9,8,7], [6,5,4,5,6,5,4]]. | |||||
| - If `mode` is "SYMMETRIC", the filling method is similar to the "REFLECT". It is also copied | - If `mode` is "SYMMETRIC", the filling method is similar to the "REFLECT". It is also copied | ||||
| according to the symmetry axis, except that it includes the symmetry axis. If the `input_x` | according to the symmetry axis, except that it includes the symmetry axis. If the `input_x` | ||||
| is [[1,2,3],[4,5,6],[7,8,9]] and `paddings` is [[1,1],[2,2]], then the Outputs is | |||||
| [[2,1,1,2,3,3,2],[2,1,1,2,3,3,2],[5,4,4,5,6,6,5],[8,7,7,8,9,9,8],[8,7,7,8,9,9,8]]. | |||||
| is [[1,2,3], [4,5,6], [7,8,9]] and `paddings` is [[1,1], [2,2]], then the Outputs is | |||||
| [[2,1,1,2,3,3,2], [2,1,1,2,3,3,2], [5,4,4,5,6,6,5], [8,7,7,8,9,9,8], [8,7,7,8,9,9,8]]. | |||||
| Supported Platforms: | Supported Platforms: | ||||
| ``Ascend`` ``GPU`` | ``Ascend`` ``GPU`` | ||||
| @@ -124,8 +124,8 @@ def clip_by_global_norm(x, clip_norm=1.0, use_norm=None): | |||||
| ``Ascend`` ``GPU`` | ``Ascend`` ``GPU`` | ||||
| Examples: | Examples: | ||||
| >>> x1 = np.array([[2., 3.],[1., 2.]]).astype(np.float32) | |||||
| >>> x2 = np.array([[1., 4.],[3., 1.]]).astype(np.float32) | |||||
| >>> x1 = np.array([[2., 3.], [1., 2.]]).astype(np.float32) | |||||
| >>> x2 = np.array([[1., 4.], [3., 1.]]).astype(np.float32) | |||||
| >>> input_x = (Tensor(x1), Tensor(x2)) | >>> input_x = (Tensor(x1), Tensor(x2)) | ||||
| >>> out = clip_by_global_norm(input_x, 1.0) | >>> out = clip_by_global_norm(input_x, 1.0) | ||||
| >>> print(out) | >>> print(out) | ||||
| @@ -701,7 +701,7 @@ class MatMul(PrimitiveWithInfer): | |||||
| Inputs: | Inputs: | ||||
| - **input_x** (Tensor) - The first tensor to be multiplied. The shape of the tensor is :math:`(N, C)`. If | - **input_x** (Tensor) - The first tensor to be multiplied. The shape of the tensor is :math:`(N, C)`. If | ||||
| `transpose_a` is True, its shape must be :math:`(N, C)` after transposing. | |||||
| `transpose_a` is True, its shape must be :math:`(N, C)` after transpose. | |||||
| - **input_y** (Tensor) - The second tensor to be multiplied. The shape of the tensor is :math:`(C, M)`. If | - **input_y** (Tensor) - The second tensor to be multiplied. The shape of the tensor is :math:`(C, M)`. If | ||||
| `transpose_b` is True, its shape must be :math:`(C, M)` after transpose. | `transpose_b` is True, its shape must be :math:`(C, M)` after transpose. | ||||
| @@ -856,7 +856,7 @@ class CumSum(PrimitiveWithInfer): | |||||
| ``Ascend`` ``GPU`` | ``Ascend`` ``GPU`` | ||||
| Examples: | Examples: | ||||
| >>> input = Tensor(np.array([[3, 4, 6, 10],[1, 6, 7, 9],[4, 3, 8, 7],[1, 3, 7, 9]]).astype(np.float32)) | |||||
| >>> input = Tensor(np.array([[3, 4, 6, 10], [1, 6, 7, 9], [4, 3, 8, 7], [1, 3, 7, 9]]).astype(np.float32)) | |||||
| >>> cumsum = ops.CumSum() | >>> cumsum = ops.CumSum() | ||||
| >>> output = cumsum(input, 1) | >>> output = cumsum(input, 1) | ||||
| >>> print(output) | >>> print(output) | ||||
| @@ -3347,12 +3347,12 @@ class MirrorPad(PrimitiveWithInfer): | |||||
| Tensor, the tensor after padding. | Tensor, the tensor after padding. | ||||
| - If `mode` is "REFLECT", it uses a way of symmetrical copying through the axis of symmetry to fill in. | - If `mode` is "REFLECT", it uses a way of symmetrical copying through the axis of symmetry to fill in. | ||||
| If the `input_x` is [[1,2,3],[4,5,6],[7,8,9]] and `paddings` is [[1,1],[2,2]], then the | |||||
| Outputs is [[6,5,4,5,6,5,4],[3,2,1,2,3,2,1],[6,5,4,5,6,5,4],[9,8,7,8,9,8,7],[6,5,4,5,6,5,4]]. | |||||
| If the `input_x` is [[1,2,3], [4,5,6], [7,8,9]] and `paddings` is [[1,1], [2,2]], then the | |||||
| Outputs is [[6,5,4,5,6,5,4], [3,2,1,2,3,2,1], [6,5,4,5,6,5,4], [9,8,7,8,9,8,7], [6,5,4,5,6,5,4]]. | |||||
| - If `mode` is "SYMMETRIC", the filling method is similar to the "REFLECT". It is also copied | - If `mode` is "SYMMETRIC", the filling method is similar to the "REFLECT". It is also copied | ||||
| according to the symmetry axis, except that it includes the symmetry axis. If the `input_x` | according to the symmetry axis, except that it includes the symmetry axis. If the `input_x` | ||||
| is [[1,2,3],[4,5,6],[7,8,9]] and `paddings` is [[1,1],[2,2]], then the Outputs is | |||||
| [[2,1,1,2,3,3,2],[2,1,1,2,3,3,2],[5,4,4,5,6,6,5],[8,7,7,8,9,9,8],[8,7,7,8,9,9,8]]. | |||||
| is [[1,2,3], [4,5,6], [7,8,9]] and `paddings` is [[1,1], [2,2]], then the Outputs is | |||||
| [[2,1,1,2,3,3,2], [2,1,1,2,3,3,2], [5,4,4,5,6,6,5], [8,7,7,8,9,9,8], [8,7,7,8,9,9,8]]. | |||||
| Supported Platforms: | Supported Platforms: | ||||
| ``Ascend`` ``GPU`` | ``Ascend`` ``GPU`` | ||||
| @@ -3370,7 +3370,7 @@ class MirrorPad(PrimitiveWithInfer): | |||||
| ... return self.pad(x, paddings) | ... return self.pad(x, paddings) | ||||
| ... | ... | ||||
| >>> x = np.random.random(size=(2, 3)).astype(np.float32) | >>> x = np.random.random(size=(2, 3)).astype(np.float32) | ||||
| >>> paddings = Tensor([[1,1],[2,2]]) | |||||
| >>> paddings = Tensor([[1, 1], [2, 2]]) | |||||
| >>> pad = Net() | >>> pad = Net() | ||||
| >>> output = pad(Tensor(x), paddings) | >>> output = pad(Tensor(x), paddings) | ||||
| >>> print(output.shape) | >>> print(output.shape) | ||||
| @@ -128,8 +128,8 @@ class BoundingBoxEncode(PrimitiveWithInfer): | |||||
| ``Ascend`` ``GPU`` | ``Ascend`` ``GPU`` | ||||
| Examples: | Examples: | ||||
| >>> anchor_box = Tensor([[4,1,2,1],[2,2,2,3]],mindspore.float32) | |||||
| >>> groundtruth_box = Tensor([[3,1,2,2],[1,2,1,4]],mindspore.float32) | |||||
| >>> anchor_box = Tensor([[4, 1, 2, 1], [2, 2, 2, 3]], mindspore.float32) | |||||
| >>> groundtruth_box = Tensor([[3, 1, 2, 2], [1, 2, 1, 4]], mindspore.float32) | |||||
| >>> boundingbox_encode = ops.BoundingBoxEncode(means=(0.0, 0.0, 0.0, 0.0), stds=(1.0, 1.0, 1.0, 1.0)) | >>> boundingbox_encode = ops.BoundingBoxEncode(means=(0.0, 0.0, 0.0, 0.0), stds=(1.0, 1.0, 1.0, 1.0)) | ||||
| >>> output = boundingbox_encode(anchor_box, groundtruth_box) | >>> output = boundingbox_encode(anchor_box, groundtruth_box) | ||||
| >>> print(output) | >>> print(output) | ||||
| @@ -184,8 +184,8 @@ class BoundingBoxDecode(PrimitiveWithInfer): | |||||
| ``Ascend`` ``GPU`` | ``Ascend`` ``GPU`` | ||||
| Examples: | Examples: | ||||
| >>> anchor_box = Tensor([[4,1,2,1],[2,2,2,3]],mindspore.float32) | |||||
| >>> deltas = Tensor([[3,1,2,2],[1,2,1,4]],mindspore.float32) | |||||
| >>> anchor_box = Tensor([[4, 1, 2, 1], [2, 2, 2, 3]], mindspore.float32) | |||||
| >>> deltas = Tensor([[3, 1, 2, 2], [1, 2, 1, 4]], mindspore.float32) | |||||
| >>> boundingbox_decode = ops.BoundingBoxDecode(means=(0.0, 0.0, 0.0, 0.0), stds=(1.0, 1.0, 1.0, 1.0), | >>> boundingbox_decode = ops.BoundingBoxDecode(means=(0.0, 0.0, 0.0, 0.0), stds=(1.0, 1.0, 1.0, 1.0), | ||||
| ... max_shape=(768, 1280), wh_ratio_clip=0.016) | ... max_shape=(768, 1280), wh_ratio_clip=0.016) | ||||
| >>> output = boundingbox_decode(anchor_box, deltas) | >>> output = boundingbox_decode(anchor_box, deltas) | ||||
| @@ -560,7 +560,7 @@ class UniformCandidateSampler(PrimitiveWithInfer): | |||||
| Examples: | Examples: | ||||
| >>> sampler = ops.UniformCandidateSampler(1, 3, False, 4) | >>> sampler = ops.UniformCandidateSampler(1, 3, False, 4) | ||||
| >>> output1, output2, output3 = sampler(Tensor(np.array([[1],[3],[4],[6],[3]], dtype=np.int32))) | |||||
| >>> output1, output2, output3 = sampler(Tensor(np.array([[1], [3], [4], [6], [3]], dtype=np.int32))) | |||||
| >>> print(output1, output2, output3) | >>> print(output1, output2, output3) | ||||
| [1, 1, 3], [[0.75], [0.75], [0.75], [0.75], [0.75]], [0.75, 0.75, 0.75] | [1, 1, 3], [[0.75], [0.75], [0.75], [0.75], [0.75]], [0.75, 0.75, 0.75] | ||||
| """ | """ | ||||