YouTip LogoYouTip

Pytorch Torch Addcdiv

# PyTorch torch.addcdiv Function * * Pytorch torch reference manual](#) `torch.addcdiv` is a function in PyTorch used to perform element-wise operation `input + value * (tensor1 / tensor2)`. ### Function Definition torch.addcdiv(input, tensor1, tensor2, value=1, out=None) ### Parameter Description * `input`: Input tensor * `tensor1`: Numerator tensor * `tensor2`: Denominator tensor (cannot be zero) * `value`: Multiplier, default is 1 * `out`: Output tensor (optional) * * * ## Usage Example ## Example import torch # Create 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) print(result) Output: tensor([3., 6., 9.]) * * Pytorch torch reference manual](#)
← Pytorch Torch AddmmPytorch Torch Add β†’