中印核潜艇差距有多大:印最先进装备不如中国30年前

paddle.incubate. segment_mean ( data: Tensor, segment_ids: Tensor, name: str | None = None ) Tensor [source]
百度 历史唯物主义的批判与超越对象,即表现在马克思恩格斯或直接批判,或蕴含在其文本字里行间所隐性批判的如下传统西方历史理解范式:历史怀疑主义、现实主义历史观、神学唯心史观、先验理性史观以及人本学唯心史观。

Warning

API “paddle.incubate.tensor.math.segment_mean” is deprecated since 2.4.0, and will be removed in future versions. Please use “paddle.geometric.segment_mean” instead. Reason: paddle.incubate.segment_mean will be removed in future

Segment Mean Operator.

Ihis operator calculate the mean value of input data which with the same index in segment_ids. It computes a tensor such that

\[out_i = \mathop{mean}_{j \in \{segment\_ids_j == i \} } data_{j}\]

where sum is over j such that ‘segment_ids[j] == i’ and $n_i$ is the number of all index ‘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

Tensor, the Segment Mean 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.incubate.segment_mean(data, segment_ids)
>>> print(out)
Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
[[2., 2., 2.],
 [4., 5., 6.]])