• 文档 >
  • torch >
  • torch.lerp
快捷键

torch.lerp

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

根据标量或张量 weight 对两个张量 start (由 input 给出)和 end 进行线性插值,并返回结果张量 out

outi=starti+weighti×(endistarti)\text{out}_i = \text{start}_i + \text{weight}_i \times (\text{end}_i - \text{start}_i)

startend 的形状必须可广播。如果 weight 是张量,则 weightstartend 的形状必须可广播。

参数:
  • 输入(张量)- 包含起始点的张量

  • 结束(张量)- 包含结束点的张量

  • 权重(浮点数或张量)- 插值公式的权重

关键字参数:

输出(张量,可选)- 输出张量。

示例:

>>> 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])

© 版权所有 PyTorch 贡献者。

使用 Sphinx 构建,并使用 Read the Docs 提供的主题。

文档

PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源