计算沿张量段的乘积。
用法
tf.raw_ops.UnsortedSegmentProd(
data, segment_ids, num_segments, name=None
)参数
-
data一个Tensor。必须是以下类型之一:float32,float64,int32,uint8,int16,int8,complex64,int64,qint8,quint8,qint32,bfloat16,uint16,complex128,half,uint32,uint64。 -
segment_idsATensor.必须是以下类型之一:int32,int64.形状为前缀的张量data.shape.值必须小于num_segments.警告:这些值始终在 CPU 上验证为在范围内,从不在 GPU 上验证。
-
num_segments一个Tensor。必须是以下类型之一:int32、int64。 -
name操作的名称(可选)。
返回
-
一个
Tensor。具有与data相同的类型。
阅读the section on segmentation 以了解段的解释。
此运算符类似于 tf.math.unsorted_segment_sum ,它不是计算段的总和,而是计算属于一个段的所有条目的乘积,这样:
乘积超过元组 j... 使得 segment_ids[j...] == i 。
例如:
c = tf.constant([[1,2,3,4], [5,6,7,8], [4,3,2,1]])
tf.math.unsorted_segment_prod(c, tf.constant([0, 1, 0]), num_segments=2).numpy()
array([[4, 6, 6, 4],
[5, 6, 7, 8]], dtype=int32)
如果给定的段 ID i 没有条目,则输出 1。
如果给定的段 ID i 为负,则删除相应的值,并且不会包含在结果中。警告:在 CPU 上,始终验证 segment_ids 中的值小于 num_segments ,并且超出范围的索引会引发错误。在 GPU 上,这不会为超出范围的索引引发错误。在 Gpu 上,越界索引会导致安全但未指定的行为,其中可能包括忽略越界索引或在 num_segments 为 0 时输出存储在其形状的第一维中的 0 的张量。
相关用法
- Python tf.raw_ops.UnsortedSegmentJoin用法及代码示例
- Python tf.raw_ops.UnsortedSegmentSum用法及代码示例
- Python tf.raw_ops.UnsortedSegmentMin用法及代码示例
- Python tf.raw_ops.UnsortedSegmentMax用法及代码示例
- Python tf.raw_ops.UniqueWithCounts用法及代码示例
- Python tf.raw_ops.UnicodeScript用法及代码示例
- Python tf.raw_ops.UniqueV2用法及代码示例
- Python tf.raw_ops.Unique用法及代码示例
- Python tf.raw_ops.UnicodeTranscode用法及代码示例
- Python tf.raw_ops.UnicodeEncode用法及代码示例
- Python tf.raw_ops.UnravelIndex用法及代码示例
- Python tf.raw_ops.UniqueWithCountsV2用法及代码示例
- Python tf.raw_ops.TPUReplicatedInput用法及代码示例
- Python tf.raw_ops.Bitcast用法及代码示例
- Python tf.raw_ops.SelfAdjointEigV2用法及代码示例
- Python tf.raw_ops.BatchMatMul用法及代码示例
- Python tf.raw_ops.OneHot用法及代码示例
- Python tf.raw_ops.ResourceScatterNdSub用法及代码示例
- Python tf.raw_ops.ReadVariableXlaSplitND用法及代码示例
- Python tf.raw_ops.GatherV2用法及代码示例
- Python tf.raw_ops.SegmentMean用法及代码示例
- Python tf.raw_ops.Expm1用法及代码示例
- Python tf.raw_ops.DecodeGif用法及代码示例
- Python tf.raw_ops.Size用法及代码示例
- Python tf.raw_ops.ScatterUpdate用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.raw_ops.UnsortedSegmentProd。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
