Browse Source

!15561 Update MindSpore Doc Topk,Unique,UniqueWithPad

From: @dinglinhe123
Reviewed-by: @liangchenghui,@wuxuejian
Signed-off-by: @liangchenghui
pull/15561/MERGE
mindspore-ci-bot Gitee 5 years ago
parent
commit
7043542e65
3 changed files with 26 additions and 0 deletions
  1. +12
    -0
      mindspore/ops/operations/array_ops.py
  2. +4
    -0
      mindspore/ops/operations/math_ops.py
  3. +10
    -0
      mindspore/ops/operations/nn_ops.py

+ 12
- 0
mindspore/ops/operations/array_ops.py View File

@@ -766,6 +766,12 @@ class Unique(Primitive):
Returns the unique elements of input tensor and also return a tensor containing the index of each value of input
tensor corresponding to the output unique tensor.

This operation returns a tuple that contains the tensor `y` and the tensor `idx`;
where the tensor `y` contains unique elements along the `axis` of the tensor.
The sorting order of the unique elements is the same as the order that
they appear along the `axis` in `x`. Another tensor `idx` has the same size as the number of elements in `x`
along the `axis` dimension. It contains the index in the unique output `y`.

Inputs:
- **x** (Tensor) - The input tensor.

@@ -975,6 +981,12 @@ class UniqueWithPad(PrimitiveWithInfer):
"""
Returns unique elements and relative indexes in 1-D tensor, filled with padding num.

The basic function is the same as the Unique operator, but the operator adds a Pad function.
The returned tuple(`y`,`idx`) after the input tensor x is processed by the unique operator,
in which the shapes of `y` and `idx` are mostly not equal. Therefore, in order to solve the above situation,
the UniqueWithPad operator will fill the `y` tensor with the number specified by the user
to make it have the same shape as the tensor `idx`.

Inputs:
- **x** (Tensor) - The tensor need to be unique. Must be 1-D vector with types: int32, int64.
- **pad_num** (int) - Pad num.


+ 4
- 0
mindspore/ops/operations/math_ops.py View File

@@ -1421,6 +1421,10 @@ class SquaredDifference(_MathBinaryOp):
When the inputs are one tensor and one scalar,
the scalar could only be a constant.

.. math::

out_{i} = (x_{i} + y_{i}) * (x_{i} - y_{i}) = x_{i}^2 - y_{i}^2

Inputs:
- **input_x** (Union[Tensor, Number, bool]) - The first input is a number, or a bool,
or a tensor whose data type is float16, float32, int32 or bool.


+ 10
- 0
mindspore/ops/operations/nn_ops.py View File

@@ -2106,6 +2106,16 @@ class TopK(PrimitiveWithInfer):
"""
Finds values and indices of the `k` largest entries along the last dimension.

If the input is a one-dimensional Tensor, find the k largest entries in the Tensor,
and output its value and index as a Tensor. Therefore, "values [k]" is the "k" largest item in "input",
and its index is "indices [k]".

For a multi-dimensional matrix,
calculate the first k entries in each row (corresponding vector along the last dimension), therefore:
values.shape = indices.shape = input.shape[:-1] + [k].

If the two compared elements are the same, the one with the smaller index value is returned first.

Args:
sorted (bool): If true, the obtained elements will
be sorted by the values in descending order. Default: False.


Loading…
Cancel
Save