lerp

paddle. lerp ( x, y, weight, name=None ) [source]

Does a linear interpolation between x and y based on weight.

Equation:
\[lerp(x, y, weight) = x + weight * (y - x).\]
Parameters
  • x (Tensor) – An N-D Tensor with starting points, the data type is bfloat16, float16, float32, float64.

  • y (Tensor) – An N-D Tensor with ending points, the data type is bfloat16, float16, float32, float64.

  • weight (float|Tensor) – The weight for the interpolation formula. When weight is Tensor, the data type is bfloat16, float16, float32, float64.

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

Returns

An N-D Tensor, the shape and data type is the same with input.

Return type

out (Tensor)

Example

>>> import paddle

>>> x = paddle.arange(1., 5., dtype='float32')
>>> y = paddle.empty([4], dtype='float32')
>>> y.fill_(10.)
>>> out = paddle.lerp(x, y, 0.5)
>>> out
Tensor(shape=[4], dtype=float32, place=Place(cpu), stop_gradient=True,
[5.50000000, 6.        , 6.50000000, 7.        ])