快捷方式

torch.lerp

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

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

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

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

参数
  • input (Tensor) – 起始点的张量

  • end (Tensor) – 终点的张量

  • weight (floattensor) – 插值公式的权重

关键字参数

out (Tensor, optional) – 输出张量。

示例

>>> 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 的综合开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

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

查看资源