- paddle. lerp ( x, y, weight, name=None ) [source]
Does a linear interpolation between x and y based on weight.
\[lerp(x, y, weight) = x + weight * (y - x).\]
x (Tensor) – An N-D Tensor with starting points, the data type is float32, float64.
y (Tensor) – An N-D Tensor with ending points, the data type is float32, float64.
weight (float|Tensor) – The weight for the interpolation formula. When weight is Tensor, the data type is float32, float64.
name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
An N-D Tensor, the shape and data type is the same with input.
- Return type
import paddle x = paddle.arange(1., 5., dtype='float32') y = paddle.empty(, dtype='float32') y.fill_(10.) out = paddle.lerp(x, y, 0.5) # out: [5.5, 6., 6.5, 7.]