torch.addcmul¶
- torch.addcmul(input, tensor1, tensor2, *, value=1, out=None) Tensor¶
對
tensor1和tensor2進行逐元素乘法,將結果乘以標量value並加到input中。input、tensor1和tensor2的形狀必須是可廣播的。對於 FloatTensor 或 DoubleTensor 型別的輸入,
value必須是實數,否則為整數。- 引數
- 關鍵字引數
value (Number, 可選) – `tensor1 .* tensor2` 的乘數
out (Tensor, 可選) – 輸出張量。
示例
>>> 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]])