当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python tf.raw_ops.SegmentSum用法及代码示例


计算沿张量段的总和。

用法

tf.raw_ops.SegmentSum(
    data, segment_ids, name=None
)

参数

  • data 一个Tensor。必须是以下类型之一:float32 , float64 , int32 , uint8 , int16 , int8 , complex64 , int64 , qint8 , quint8 , qint32 , bfloat16 , uint16 , complex128 , half , uint32 , uint64
  • segment_ids 一个Tensor。必须是以下类型之一:int32int64。一维张量,其大小等于 data 的第一个维度的大小。值应该排序并且可以重复。
  • name 操作的名称(可选)。

返回

  • 一个Tensor。具有与 data 相同的类型。

阅读the section on segmentation 以了解段的解释。

计算一个张量,使得 其中总和超过 j 使得 segment_ids[j] == i

如果给定段 ID ioutput[i] = 0 的总和为空。

例如:

c = tf.constant([[1,2,3,4], [4, 3, 2, 1], [5,6,7,8]])
tf.math.segment_sum(c, tf.constant([0, 0, 1]))
# ==> [[5, 5, 5, 5],
#      [5, 6, 7, 8]]

相关用法


注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.raw_ops.SegmentSum。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。