計算沿張量段的總和。
用法
tf.math.unsorted_segment_sum(
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 以了解段的解釋。
計算一個張量,使得 總和超過元組 j... 使得 segment_ids[j...] == i 。與 SegmentSum 不同,segment_ids 不需要排序,也不需要覆蓋整個有效值範圍內的所有值。
如果給定段 ID i 、 output[i] = 0 的總和為空。如果給定的段 ID i 為負,則該值將被丟棄並且不會添加到段的總和中。
num_segments 應等於不同段 ID 的數量。
警告:在 CPU 上,始終驗證 segment_ids 中的值小於 num_segments ,並且針對越界索引引發錯誤。在 GPU 上,這不會為超出範圍的索引引發錯誤。在 Gpu 上,越界索引會導致安全但未指定的行為,其中可能包括忽略越界索引或在 num_segments 為 0 時輸出存儲在其形狀的第一維中的 0 的張量。
c = [[1,2,3,4], [5,6,7,8], [4,3,2,1]]
tf.math.unsorted_segment_sum(c, [0, 1, 0], num_segments=2).numpy()
array([[5, 5, 5, 5],
[5, 6, 7, 8]], dtype=int32)
相關用法
- Python tf.math.unsorted_segment_min用法及代碼示例
- Python tf.math.unsorted_segment_prod用法及代碼示例
- Python tf.math.unsorted_segment_max用法及代碼示例
- Python tf.math.special.fresnel_cos用法及代碼示例
- Python tf.math.is_finite用法及代碼示例
- Python tf.math.special.bessel_k0e用法及代碼示例
- Python tf.math.acosh用法及代碼示例
- Python tf.math.invert_permutation用法及代碼示例
- Python tf.math.segment_prod用法及代碼示例
- Python tf.math.bincount用法及代碼示例
- Python tf.math.bessel_i0e用法及代碼示例
- Python tf.math.special.bessel_j0用法及代碼示例
- Python tf.math.conj用法及代碼示例
- Python tf.math.scalar_mul用法及代碼示例
- Python tf.math.zero_fraction用法及代碼示例
- Python tf.math.reduce_max用法及代碼示例
- Python tf.math.special.fresnel_sin用法及代碼示例
- Python tf.math.segment_mean用法及代碼示例
- Python tf.math.xlog1py用法及代碼示例
- Python tf.math.less_equal用法及代碼示例
- Python tf.math.reduce_min用法及代碼示例
- Python tf.math.log_sigmoid用法及代碼示例
- Python tf.math.count_nonzero用法及代碼示例
- Python tf.math.not_equal用法及代碼示例
- Python tf.math.cumulative_logsumexp用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.math.unsorted_segment_sum。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
