cumsum¶
- paddle.fluid.layers.ops. cumsum ( x, axis=None, exclusive=None, reverse=None ) [source]
-
- alias_main
-
paddle.cumsum
- alias
-
paddle.cumsum,paddle.tensor.cumsum,paddle.tensor.math.cumsum
- old_api
-
paddle.fluid.layers.cumsum
The cumulative sum of the elements along a given axis. By default, the first element of the result is the same of the first element of the input. If exlusive is true, the first element of the result is 0.
- Parameters
-
x (Variable) – Input of cumsum operator, the Tensor/LoDTensor needed to be cumsumed.
axis (int, optional) – The dimension to accumulate along. -1 means the last dimension. Default is -1.
exclusive (bool, optional) – Whether to perform exclusive cumsum. Default is False.
reverse (bool, optional) – If true, the cumsum is performed in the reversed direction. Default is False.
- Returns
-
The result of cumsum operator, output of cumsum operator.
- Return type
-
Variable(Tensor/LoDTensor)
Examples
import paddle.fluid as fluid data = fluid.layers.data(name="input", shape=[32, 784]) result = fluid.layers.cumsum(data, axis=0)