计算张量 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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
