
Last chance! 50% off unlimited learning
Sale ends in
Div
(Tensor) the input tensor.
(Number) the number to be divided to each element of input
Divides each element of the input input
with the scalar other
and
returns a new resulting tensor.
Each element of the tensor input
is divided by each element of the tensor
other
. The resulting tensor is returned.
input
and other
must be broadcastable
. If the torch_dtype
of input
and
other
differ, the torch_dtype
of the result tensor is determined
following rules described in the type promotion documentation
. If out
is specified, the result must be
castable to the torch_dtype
of the
specified output tensor. Integral division by zero leads to undefined behavior.
Integer division using div is deprecated, and in a future release div will
perform true division like torch_true_divide
.
Use torch_floor_divide
(// in Python) to perform integer division,
instead.
torch_dtype
of input
and other
differ, the
torch_dtype
of the result tensor is determined following rules
described in the type promotion documentation . If
out
is specified, the result must be castable
to the torch_dtype
of the specified output tensor. Integral division
by zero leads to undefined behavior.
# NOT RUN {
if (torch_is_installed()) {
a = torch_randn(c(5))
a
torch_div(a, 0.5)
a = torch_randn(c(4, 4))
a
b = torch_randn(c(4))
b
torch_div(a, b)
}
# }
Run the code above in your browser using DataLab