codecamp

计算张量沿轴的累积积

tf.cumprod

cumprod ( 
    x , 
    axis = 0 , 
    exclusive = False , 
    reverse = False , 
    name = None
 )

定义在:tensorflow/python/ops/math_ops.py.

参见指南:数学函数>张量扫描

计算张量 x 沿轴的累积积.

默认情况下,此 op 执行包含的 cumprod,这意味着输入的第一个元素与输出的第一个元素相同:

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

通过将专有的 kwarg 设置为 True,将执行一个独占的 cumprod:

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

通过将反向 kwarg 设置为 True, cumprod 将以相反的方向执行:

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

这比使用单独的 tf.reverse 操作更有效.反向和专有的 kwargs 也可以组合在一起:

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

ARGS:

  • x:张量.必须是下列类型之一:float32,float64,int64,int32,uint8,uint16,int16,int8,complex64,complex128,qint8,quint8,qint32,half.
  • axis:int32 类型的张量(默认值:0).
  • exclusive:如果为 True,则执行独占 cumprod.
  • reverse:布尔值(默认值:False).
  • name:操作的名称(可选).

返回:

返回一个张量,与 x 具有相同的类型.

TensorFlow怎么创建分区变量列表
TensorFlow张量的累积和
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }