沿張量的稀疏段計算總和。
用法
tf.raw_ops.SparseSegmentSumWithNumSegments(
data, indices, segment_ids, num_segments, name=None
)參數
-
data一個Tensor。必須是以下類型之一:float32,float64,int32,uint8,int16,int8,int64,bfloat16,uint16,half,uint32,uint64。 -
indices一個Tensor。必須是以下類型之一:int32,int64。一維張量。與segment_ids具有相同的等級。 -
segment_ids一個Tensor。必須是以下類型之一:int32,int64。一維張量。值應該排序並且可以重複。 -
num_segments一個Tensor。必須是以下類型之一:int32,int64。應等於不同段 ID 的數量。 -
name操作的名稱(可選)。
返回
-
一個
Tensor。具有與data相同的類型。
與 SparseSegmentSum 類似,但允許在 segment_ids 中缺少 id。如果缺少 id,則該位置的 output 張量將歸零。
閱讀分段部分以了解分段的說明。
例如:
c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]])
tf.sparse_segment_sum_with_num_segments(
c, tf.constant([0, 1]), tf.constant([0, 0]), num_segments=3)
# => [[0 0 0 0]
# [0 0 0 0]
# [0 0 0 0]]
tf.sparse_segment_sum_with_num_segments(c,
tf.constant([0, 1]),
tf.constant([0, 2],
num_segments=4))
# => [[ 1 2 3 4]
# [ 0 0 0 0]
# [-1 -2 -3 -4]
# [ 0 0 0 0]]
相關用法
- Python tf.raw_ops.SparseSegmentSum用法及代碼示例
- Python tf.raw_ops.SparseSlice用法及代碼示例
- Python tf.raw_ops.SparseSplit用法及代碼示例
- Python tf.raw_ops.SparseCrossV2用法及代碼示例
- Python tf.raw_ops.SparseCross用法及代碼示例
- Python tf.raw_ops.SparseConcat用法及代碼示例
- Python tf.raw_ops.SparseMatrixSparseMatMul用法及代碼示例
- Python tf.raw_ops.SparseMatrixOrderingAMD用法及代碼示例
- Python tf.raw_ops.SparseFillEmptyRows用法及代碼示例
- Python tf.raw_ops.SparseToDense用法及代碼示例
- Python tf.raw_ops.SparseMatrixSparseCholesky用法及代碼示例
- Python tf.raw_ops.SparseMatrixMatMul用法及代碼示例
- Python tf.raw_ops.SparseCrossHashed用法及代碼示例
- Python tf.raw_ops.SpaceToDepth用法及代碼示例
- Python tf.raw_ops.SpaceToBatch用法及代碼示例
- Python tf.raw_ops.SpaceToBatchND用法及代碼示例
- Python tf.raw_ops.SelfAdjointEigV2用法及代碼示例
- Python tf.raw_ops.Size用法及代碼示例
- Python tf.raw_ops.ScatterUpdate用法及代碼示例
- Python tf.raw_ops.ScatterNdUpdate用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.raw_ops.SparseSegmentSumWithNumSegments。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
