tf.raw_ops.SparseSegmentSum
Вычисляет сумму по разреженным сегментам тензора.
tf.raw_ops.SparseSegmentSum(
data, indices, segment_ids, name=None
)
Прочитайте раздел о сегментации для объяснения сегментов.
Как и SegmentSum, но segment_ids может иметь ранг меньше, чем первый размер data, выбирая подмножество измерения 0, указанное indices.
Например:
c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]]) # Select two rows, one segment. tf.sparse_segment_sum(c, tf.constant([0, 1]), tf.constant([0, 0])) # => [[0 0 0 0]] # Select two rows, two segment. tf.sparse_segment_sum(c, tf.constant([0, 1]), tf.constant([0, 1])) # => [[ 1 2 3 4] # [-1 -2 -3 -4]] # Select all rows, two segments. tf.sparse_segment_sum(c, tf.constant([0, 1, 2]), tf.constant([0, 0, 1])) # => [[0 0 0 0] # [5 6 7 8]] # Which is equivalent to: tf.segment_sum(c, tf.constant([0, 0, 1]))
| Аргументы | |
|---|---|
data | A Tensor. Должен быть одним из следующих типов: float32, float64, int32, uint8, int16, int8, int64, bfloat16, uint16, half, uint32, uint64. |
indices | A Tensor. Должен быть одним из следующих типов: int32, int64. 1-мерный тензор. Имеет такой же ранг, как segment_ids. |
segment_ids | A Tensor. Должен быть одним из следующих типов: int32, int64. 1-мерный тензор. Значения должны быть отсортированы и могут повторяться. |
name | Имя операции (необязательно). |
| Возвращает | |
|---|---|
A Tensor. Имеет тот же тип, что и data. |
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/python/tf/raw_ops/SparseSegmentSum