codecamp

TensorFlow张量的累积和

tf.cumsum

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

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

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

计算张量 x 沿轴的累积总和.
默认情况下,此操作执行一个包含性的 cumsum,这意味着输入的第一个元素与输出的第一个元素相同:

tf.cumsum([a, b, c])  # => [a, a + b, a + b + c]

通过将 exclusive kwarg 设置为 True,执行专用的 cumsum:

tf.cumsum([a, b, c], exclusive = True)  # => [0, a, a + b]

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

tf.cumsum([a, b, c], reverse=True)  # => [a + b + c, b + c, c]

比这使用单独的 tf.reverse 操作更加有效.

reverse 和 exclusive kwargs 也可以组合在一起:

tf.cumsum([a, b, c], exclusive=True, reverse=True)  # => [b + c, c, 0]

ARGS:

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

返回:

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

计算张量沿轴的累积积
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; }