paddle. increment ( x, value=1.0, name=None ) [source]

The OP is usually used for control flow to increment the data of x by an amount value. Notice that the number of elements in x must be equal to 1.

  • x (Tensor) – A tensor that must always contain only one element, its data type supports float32, float64, int32 and int64.

  • value (float, optional) – The amount to increment the data of x. Default: 1.0.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.


Tensor, the elementwise-incremented tensor with the same shape and data type as x.


import paddle

data = paddle.zeros(shape=[1], dtype='float32')
counter = paddle.increment(data)
# [1.]