Stay organized with collections
Save and categorize content based on your preferences.
tensorflow::
ops::
Cumsum
#include <math_ops.h>
Compute the cumulative sum of the tensor
x
along
axis
.
Summary
By default, this op performs an inclusive cumsum, which means that the first element of the input is identical to the first element of the output:
tf.cumsum([a, b, c]) # => [a, a + b, a + b + c]
By setting the
exclusive
kwarg to
True
, an exclusive cumsum is performed instead:
tf.cumsum([a, b, c], exclusive=True) # => [0, a, a + b]
By setting the
reverse
kwarg to
True
, the cumsum is performed in the opposite direction:
tf.cumsum([a, b, c], reverse=True) # => [a + b + c, b + c, c]
This is more efficient than using separate
tf.reverse
ops.
The
reverse
and
exclusive
kwargs can also be combined:
tf.cumsum([a, b, c], exclusive=True, reverse=True) # => [b + c, c, 0]
Args:
-
scope: A
Scope
object
-
x: A
Tensor
. Must be one of the following types:
float32
,
float64
,
int64
,
int32
,
uint8
,
uint16
,
int16
,
int8
,
complex64
,
complex128
,
qint8
,
quint8
,
qint32
,
half
.
-
axis: A
Tensor
of type
int32
(default: 0). Must be in the range
[-rank(x), rank(x))
.
Optional attributes (see
Attrs
):
-
exclusive: If
True
, perform exclusive cumsum.
-
reverse: A
bool
(default: False).
Returns:
Public attributes
Public functions
node
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
Public static functions
Exclusive
Attrs Exclusive(
bool x
)
Reverse
Attrs Reverse(
bool x
)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2021-05-14 UTC.
[null,null,["Last updated 2021-05-14 UTC."],[],[],null,["# tensorflow::ops::Cumsum Class Reference\n\ntensorflow::\nops::\nCumsum\n=========================\n\n`\n#include \u003cmath_ops.h\u003e\n`\n\n\nCompute the cumulative sum of the tensor\n`\nx\n`\nalong\n`\naxis\n`\n.\n\nSummary\n-------\n\n\nBy default, this op performs an inclusive cumsum, which means that the first element of the input is identical to the first element of the output:\n\n\n```text\ntf.cumsum([a, b, c]) # =\u003e [a, a + b, a + b + c]\n```\n\n\u003cbr /\u003e\n\n\nBy setting the\n`\nexclusive\n`\nkwarg to\n`\nTrue\n`\n, an exclusive cumsum is performed instead:\n\n\n```text\ntf.cumsum([a, b, c], exclusive=True) # =\u003e [0, a, a + b]\n```\n\n\u003cbr /\u003e\n\n\nBy setting the\n`\nreverse\n`\nkwarg to\n`\nTrue\n`\n, the cumsum is performed in the opposite direction:\n\n\n```text\ntf.cumsum([a, b, c], reverse=True) # =\u003e [a + b + c, b + c, c]\n```\n\n\u003cbr /\u003e\n\n\nThis is more efficient than using separate\n`\ntf.reverse\n`\nops.\n\n\nThe\n`\nreverse\n`\nand\n`\nexclusive\n`\nkwargs can also be combined:\n\n\n```text\ntf.cumsum([a, b, c], exclusive=True, reverse=True) # =\u003e [b + c, c, 0]\n```\n\n\u003cbr /\u003e\n\n\nArgs:\n\n- scope: A [Scope](/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- x: A `\n `[Tensor](/versions/r2.5/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor)`\n ` . Must be one of the following types: `\n float32\n ` , `\n float64\n ` , `\n int64\n ` , `\n int32\n ` , `\n uint8\n ` , `\n uint16\n ` , `\n int16\n ` , `\n int8\n ` , `\n complex64\n ` , `\n complex128\n ` , `\n qint8\n ` , `\n quint8\n ` , `\n qint32\n ` , `\n half\n ` .\n- axis: A `\n `[Tensor](/versions/r2.5/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor)`\n ` of type `\n int32\n ` (default: 0). Must be in the range `\n [-rank(x), rank(x))\n ` .\n\n\u003cbr /\u003e\n\n\nOptional attributes (see\n`\n`[Attrs](/versions/r2.5/api_docs/cc/struct/tensorflow/ops/cumsum/attrs#structtensorflow_1_1ops_1_1_cumsum_1_1_attrs)`\n`\n):\n\n- exclusive: If `\n True\n ` , perform exclusive cumsum.\n- reverse: A `\n bool\n ` (default: False).\n\n\u003cbr /\u003e\n\n\nReturns:\n\n- `\n `[Output](/versions/r2.5/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output)`\n ` : The out tensor.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| ` `[Cumsum](#classtensorflow_1_1ops_1_1_cumsum_1ac4bff34c1fffc1a64355bd97e38887d2)` (const :: `[tensorflow::Scope](/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, :: `[tensorflow::Input](/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` x, :: `[tensorflow::Input](/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` axis) ` ||\n| ` `[Cumsum](#classtensorflow_1_1ops_1_1_cumsum_1afe84204de0e7a885385374174240fcc3)` (const :: `[tensorflow::Scope](/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, :: `[tensorflow::Input](/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` x, :: `[tensorflow::Input](/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` axis, const `[Cumsum::Attrs](/versions/r2.5/api_docs/cc/struct/tensorflow/ops/cumsum/attrs#structtensorflow_1_1ops_1_1_cumsum_1_1_attrs)` & attrs) ` ||\n\n| ### Public attributes ||\n|------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|\n| ` `[operation](#classtensorflow_1_1ops_1_1_cumsum_1abe2a855b0b89aedaadef5b1ab2d495f6)` ` | ` `[Operation](/versions/r2.5/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation)` ` |\n| ` `[out](#classtensorflow_1_1ops_1_1_cumsum_1aa1249678696c8bec40fc3737ff3af4b0)` ` | ` :: `[tensorflow::Output](/versions/r2.5/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output)` ` |\n\n| ### Public functions ||\n|----------------------------------------------------------------------------------------------------------------------|--------------------------|\n| ` `[node](#classtensorflow_1_1ops_1_1_cumsum_1a638d380af05abb4f7dbdafb4d578e5c4)` () const ` | ` ::tensorflow::Node * ` |\n| ` `[operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_cumsum_1a433ea12bc76c446dca36009246b62bb4)` () const ` | ` ` |\n| ` `[operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_cumsum_1a273a98f7b496769e405300dc1b76addd)` () const ` | ` ` |\n\n| ### Public static functions ||\n|---------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|\n| ` `[Exclusive](#classtensorflow_1_1ops_1_1_cumsum_1a405094be636726578ca6715ceeb29637)` (bool x) ` | ` `[Attrs](/versions/r2.5/api_docs/cc/struct/tensorflow/ops/cumsum/attrs#structtensorflow_1_1ops_1_1_cumsum_1_1_attrs)` ` |\n| ` `[Reverse](#classtensorflow_1_1ops_1_1_cumsum_1affad4b03f430a883b021c21fafd4ddbf)` (bool x) ` | ` `[Attrs](/versions/r2.5/api_docs/cc/struct/tensorflow/ops/cumsum/attrs#structtensorflow_1_1ops_1_1_cumsum_1_1_attrs)` ` |\n\n| ### Structs ||\n|----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow:: ops:: Cumsum:: Attrs](/versions/r2.5/api_docs/cc/struct/tensorflow/ops/cumsum/attrs) | Optional attribute setters for [Cumsum](/versions/r2.5/api_docs/cc/class/tensorflow/ops/cumsum#classtensorflow_1_1ops_1_1_cumsum) . |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### out\n\n```text\n::tensorflow::Output out\n``` \n\nPublic functions\n----------------\n\n### Cumsum\n\n```gdscript\n Cumsum(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input x,\n ::tensorflow::Input axis\n)\n``` \n\n### Cumsum\n\n```gdscript\n Cumsum(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input x,\n ::tensorflow::Input axis,\n const Cumsum::Attrs & attrs\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n``` \n\nPublic static functions\n-----------------------\n\n### Exclusive\n\n```text\nAttrs Exclusive(\n bool x\n)\n``` \n\n### Reverse\n\n```text\nAttrs Reverse(\n bool x\n)\n```"]]