mindspore.ops.unsorted_segment_min

View Source On Gitee
mindspore.ops.unsorted_segment_min(x, segment_ids, num_segments)[source]

Compute the minimum of the input tensor along segments.

The following figure shows the calculation process of unsorted_segment_min:

../../_images/UnsortedSegmentMin.png
 output i=minj data [j]

where min over tuples j... such that segment_ids[j...]==i.

Note

  • If the segment_id i is absent in the segment_ids, then output[i] will be filled with the maximum value of the x's type.

  • The segment_ids must be non-negative tensor.

Parameters
  • x (Tensor) – The input tensor.

  • segment_ids (Tensor) – Indicate the segment to which each element belongs.

  • num_segments (Union[int, Tensor], optional) – Number of segments, it can be an int or 0-D tensor.

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> x = mindspore.tensor([[1, 2, 3], [4, 5, 6], [4, 2, 1]])
>>> segment_ids = mindspore.tensor([0, 1, 1])
>>> num_segments = 2
>>> mindspore.ops.unsorted_segment_min(x, segment_ids, num_segments)
Tensor(shape=[2, 3], dtype=Int64, value=
[[1, 2, 3],
 [4, 2, 1]])