oneflow.lerp

oneflow.lerp(start, end, weight)Tensor

The documentation is referenced from: https://pytorch.org/docs/stable/generated/torch.lerp.html.

Does a linear interpolation of two tensors start and end based on a scalar or tensor weight and returns the result.

The shapes of start` and end must be broadcastable. If weight is a tensor, then the shapes of weight, start, and end must be broadcastable.

\[out_{i} = start_{i} + weight_{i} * (end_{i} - start_{i})\]
Parameters

For example:

>>> import oneflow as flow
>>> start = flow.arange(1., 5.)
>>> end = flow.empty(4).fill_(10)
>>> flow.lerp(start, end, 0.5)
tensor([5.5000, 6.0000, 6.5000, 7.0000], dtype=oneflow.float32)
>>> flow.lerp(start, end, flow.full_like(start, 0.5))
tensor([5.5000, 6.0000, 6.5000, 7.0000], dtype=oneflow.float32)