Skip to contents

Addcdiv

Usage

torch_addcdiv(self, tensor1, tensor2, value = 1L)

Arguments

self

(Tensor) the tensor to be added

tensor1

(Tensor) the numerator tensor

tensor2

(Tensor) the denominator tensor

value

(Number, optional) multiplier for tensor1/tensor2

addcdiv(input, tensor1, tensor2, *, value=1, out=NULL) -> Tensor

Performs the element-wise division of tensor1 by tensor2, multiply the result by the scalar value and add it to input.

Warning

Integer division with addcdiv is deprecated, and in a future release addcdiv will perform a true division of tensor1 and tensor2. The current addcdiv behavior can be replicated using torch_floor_divide() for integral inputs (input + value * tensor1 // tensor2) and torch_div() for float inputs (input + value * tensor1 / tensor2). The new addcdiv behavior can be implemented with torch_true_divide() (input + value * torch.true_divide(tensor1, tensor2).

outi=inputi+value×tensor1itensor2i

The shapes of input, tensor1, and tensor2 must be broadcastable .

For inputs of type FloatTensor or DoubleTensor, value must be a real number, otherwise an integer.

Examples

if (torch_is_installed()) {

t = torch_randn(c(1, 3))
t1 = torch_randn(c(3, 1))
t2 = torch_randn(c(1, 3))
torch_addcdiv(t, t1, t2, 0.1)
}
#> torch_tensor
#> -0.3597 -0.2528 -1.8271
#> -0.1729 -0.1908 -1.8087
#>  0.1730 -0.0759 -1.7746
#> [ CPUFloatType{3,3} ]