Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.addcmul Function

PyTorch torch.addcmul Function


PyTorch torch reference manual PyTorch torch reference manual

torch.addcmul is a function in PyTorch used to perform input + value * (tensor1 * tensor2) element-wise operations.

Function definition

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

Parameter Description


Usage examples

Example

import

torch

Creating tensors

input

=

torch.

tensor

(

[

1.0

,

2.0

,

3.0

]

)

tensor1

=

torch.

tensor

(

[

2.0

,

3.0

,

4.0

]

)

tensor2

=

torch.

tensor

(

[

3.0

,

4.0

,

5.0

]

)

Perform input + value * (tensor1 * tensor2)

result

=

torch.

addcmul

(

input

,

tensor1

,

tensor2

,

value

=

1

)

print

(

result

)

The output is:

tensor([ 7., 14., 23.])


PyTorch torch reference manual PyTorch torch reference manual