當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python tf.raw_ops.Cumprod用法及代碼示例

計算張量 x 沿 axis 的累積乘積。

用法

tf.raw_ops.Cumprod(
    x, axis, exclusive=False, reverse=False, name=None
)

參數

  • x A Tensor.必須是以下類型之一:float32,float64,int32,uint8,int16,int8,complex64,int64,qint8,quint8,qint32,bfloat16,uint16,complex128,half,uint32,uint64.一種Tensor.必須是以下類型之一:float32,float64,int64,int32,uint8,uint16,int16,int8,complex64,complex128,qint8,quint8,qint32,half.
  • axis 一個Tensor。必須是以下類型之一:int32 , int64Tensor 類型為 int32(默認值:0)。必須在 [-rank(x), rank(x)) 範圍內。
  • exclusive 可選的 bool 。默認為 False 。如果 True ,執行獨占 cumprod。
  • reverse 可選的 bool 。默認為 Falsebool(默認值:False)。
  • name 操作的名稱(可選)。

返回

  • 一個Tensor。具有與 x 相同的類型。

默認情況下,此操作執行包含 cumprod,這意味著輸入的第一個元素與輸出的第一個元素相同:

tf.cumprod([a, b, c])  # => [a, a * b, a * b * c]

通過將 exclusive kwarg 設置為 True ,將執行獨占 cumprod:

tf.cumprod([a, b, c], exclusive=True)  # => [1, a, a * b]

通過將 reverse kwarg 設置為 True ,cumprod 以相反的方向執行:

tf.cumprod([a, b, c], reverse=True)  # => [a * b * c, b * c, c]

這比使用單獨的 tf.reverse 操作更有效。

reverseexclusive kwargs 也可以組合:

tf.cumprod([a, b, c], exclusive=True, reverse=True)  # => [b * c, c, 1]

相關用法


注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.raw_ops.Cumprod。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。