直播回放:新华社“民族品牌传播工程”入选企业签约仪式

paddle.geometric. segment_sum ( data: Tensor, segment_ids: Tensor, name: str | None = None ) Tensor [source]
百度 党在各根据地普遍建立“三三制”的统一战线政权,实行减租减息,实行公私兼顾、劳资两利的工商政策,团结争取了民族资产阶级、开明士绅和其他中间力量;同民主党派和无党派爱国人士建立了合作关系,获得广大的同盟者。

Segment Sum Operator.

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

Parameters
  • data (Tensor) – A tensor, available data type float32, float64, int32, int64, float16.

  • 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

  • output (Tensor), the reduced result.

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.geometric.segment_sum(data, segment_ids)
>>> print(out.numpy())
[[4. 4. 4.]
 [4. 5. 6.]]