快捷方式

torch.addcmul

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

执行 tensor1tensor2 的逐元素乘法,将结果与标量 value 相乘,并将其加到 input

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

tensortensor1tensor2 的形状必须是可广播的

对于 FloatTensorDoubleTensor 类型的输入,value 必须是实数,否则为整数。

参数
  • input (Tensor) – 要相加的张量

  • tensor1 (Tensor) – 要相乘的张量

  • tensor2 (Tensor) – 要相乘的张量

关键字参数
  • value (Number, optional) – tensor1.tensor2tensor1 .* tensor2 的乘数

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

示例

>>> 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 的全面开发者文档

查看文档

教程

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

查看教程

资源

查找开发资源并获得解答

查看资源