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

torch.addcmul

torch.addcmul(input, tensor1, tensor2, *, value=1, out=None) Tensor

tensor1 进行逐元素乘法,将结果乘以标量 value 并加到 input 上。

outi=inputi+value×tensor1i×tensor2i\text{out}_i = \text{input}_i + \text{value} \times \text{tensor1}_i \times \text{tensor2}_i

tensortensor1tensor2 的形状必须可广播。

对于 FloatTensor 或 DoubleTensor 类型的输入, value 必须是一个实数,否则为整数。

参数:
  • 输入(张量)- 要添加的张量

  • tensor1(张量)- 要乘的张量

  • tensor2(张量)- 要乘的张量

关键字参数:
  • 值(数字,可选)- tensor1.tensor2tensor1 .* tensor2 的乘数

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

示例:

>>> t = torch.randn(1, 3)
>>> t1 = torch.randn(3, 1)
>>> t2 = torch.randn(1, 3)
>>> torch.addcmul(t, t1, t2, value=0.1)
tensor([[-0.8635, -0.6391,  1.6174],
        [-0.7617, -0.5879,  1.7388],
        [-0.8353, -0.6249,  1.6511]])

© 版权所有 PyTorch 贡献者。

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

文档

查看 PyTorch 的全面开发者文档

查看文档

教程

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

查看教程

资源

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

查看资源