PyTorch torch.addcdiv Function
PyTorch torch reference manual
torch.addcdiv is a function in PyTorch used to perform input + value * (tensor1 / tensor2) element-wise operations.
Function definition
torch.addcdiv(input, tensor1, tensor2, value=1, out=None)
Parameter Description
input: the input tensortensor1: the numerator tensortensor2: the denominator tensor (must not be zero)value: the multiplier, defaulting to 1out: the output tensor (optional)
Usage examples
Example
import
torch
Creating tensors
input
=
torch.
tensor
(
[
1.0
,
2.0
,
3.0
]
)
tensor1
=
torch.
tensor
(
[
4.0
,
8.0
,
12.0
]
)
tensor2
=
torch.
tensor
(
[
2.0
,
2.0
,
2.0
]
)
Perform input + value * (tensor1 / tensor2)
result
=
torch.
addcdiv
(
input
,
tensor1
,
tensor2
,
value
=
1
)
(
result
)
The output is:
tensor([3., 6., 9.])