Table of Contents
Shortcuts

# torch.lerp

torch.lerp(input, end, weight, *, out=None)

  Does a linear interpolation of two tensors `start` (given by `input`) and `end` based on a scalar or tensor `weight` and returns the resulting `out` tensor.

  out i=start i+weight i×(end i−start i)\text{out}_i = \text{start}_i + \text{weight}_i \times (\text{end}_i - \text{start}_i) out i​=start i​+weight i​×(end i​−start i​)

  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.

  Parameters:

    - input (Tensor) – the tensor with the starting points

    - end (Tensor) – the tensor with the ending points

    - weight (float or tensor) – the weight for the interpolation formula

  Keyword Arguments:

    out (Tensor, optional) – the output tensor.

  Example:

      >>> start = torch.arange(1., 5.)
      >>> end = torch.empty(4).fill_(10)
      >>> start
      tensor([ 1.,  2.,  3.,  4.])
      >>> end
      tensor([ 10.,  10.,  10.,  10.])
      >>> torch.lerp(start, end, 0.5)
      tensor([ 5.5000,  6.0000,  6.5000,  7.0000])
      >>> torch.lerp(start, end, torch.full_like(start, 0.5))
      tensor([ 5.5000,  6.0000,  6.5000,  7.0000])

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.