segment_max

paddle.incubate. segment_max ( data, segment_ids, name=None ) [source]

Segment max operator.

This operator calculate the maximum elements of input data which with the same index in segment_ids. It computes a tensor such that $out_i = \max_{j} data_{j}$ where max is over j such that segment_ids[j] == i.

Parameters
  • data (tensor) – a tensor, available data type float32, float64, int32, int64.

  • segment_ids (tensor) – a 1-d tensor, which have the same size with the first dimension of input data. available data type is int32, int64.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

the reduced result.

Return type

output (Tensor)

Examples

import paddle
data = paddle.to_tensor([[1, 2, 3], [3, 2, 1], [4, 5, 6]], dtype='float32')
segment_ids = paddle.to_tensor([0, 0, 1], dtype='int32')
out = paddle.incubate.segment_max(data, segment_ids)
#Outputs: [[3., 2., 3.], [4., 5., 6.]]