increment

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

The API 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.

Parameters
  • 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.

Returns

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

Examples

>>> import paddle

>>> data = paddle.zeros(shape=[1], dtype='float32')
>>> counter = paddle.increment(data)
>>> counter
Tensor(shape=[1], dtype=float32, place=Place(cpu), stop_gradient=True,
[1.])