計算張量 x 沿 axis 的累積乘積。
用法
tf.math.cumprod(
x, axis=0, exclusive=False, reverse=False, name=None
)參數
-
x一個Tensor。必須是以下類型之一:float32,float64,int64,int32,uint8,uint16,int16,int8,complex64,complex128,qint8,quint8,qint32,half。 -
axisint32類型的Tensor(默認值:0)。必須在[-rank(x), rank(x))範圍內。 -
exclusive如果True,執行獨占 cumprod。 -
reversebool(默認值:False)。 -
name操作的名稱(可選)。
返回
-
一個
Tensor。具有與x相同的類型。
默認情況下,此操作執行包含 cumprod,這意味著輸入的第一個元素與輸出的第一個元素相同:
tf.math.cumprod([a, b, c]) # [a, a * b, a * b * c]
通過將 exclusive kwarg 設置為 True ,將執行獨占 cumprod:
tf.math.cumprod([a, b, c], exclusive=True) # [1, a, a * b]
通過將 reverse kwarg 設置為 True ,cumprod 以相反的方向執行:
tf.math.cumprod([a, b, c], reverse=True) # [a * b * c, b * c, c]
這比使用單獨的 tf.reverse 操作更有效。 reverse 和 exclusive kwargs 也可以組合:
tf.math.cumprod([a, b, c], exclusive=True, reverse=True) # [b * c, c, 1]
相關用法
- Python tf.math.cumulative_logsumexp用法及代碼示例
- Python tf.math.cumsum用法及代碼示例
- Python tf.math.conj用法及代碼示例
- Python tf.math.count_nonzero用法及代碼示例
- Python tf.math.confusion_matrix用法及代碼示例
- Python tf.math.ceil用法及代碼示例
- Python tf.math.cos用法及代碼示例
- Python tf.math.cosh用法及代碼示例
- Python tf.math.special.fresnel_cos用法及代碼示例
- Python tf.math.polyval用法及代碼示例
- 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.unsorted_segment_min用法及代碼示例
- Python tf.math.scalar_mul用法及代碼示例
- Python tf.math.zero_fraction用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.math.cumprod。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
