Mul
mul(input, other, out=NULL)
Multiplies each element of the input input
with the scalar
other
and returns a new resulting tensor.
$$
\mbox{out}_i = \mbox{other} \times \mbox{input}_i
$$
If input
is of type FloatTensor
or DoubleTensor
, other
should be a real number, otherwise it should be an integer
Each element of the tensor input
is multiplied by the corresponding
element of the Tensor other
. The resulting tensor is returned.
The shapes of input
and other
must be
broadcastable .
$$ \mbox{out}_i = \mbox{input}_i \times \mbox{other}_i $$
Examples
if (torch_is_installed()) {
a = torch_randn(c(3))
a
torch_mul(a, 100)
a = torch_randn(c(4, 1))
a
b = torch_randn(c(1, 4))
b
torch_mul(a, b)
}
#> torch_tensor
#> 1.8229e+00 6.1573e-01 -3.7671e-01 3.9122e-03
#> 8.1764e-01 2.7618e-01 -1.6897e-01 1.7548e-03
#> 9.2321e+00 3.1184e+00 -1.9079e+00 1.9814e-02
#> -1.1543e-02 -3.8989e-03 2.3854e-03 -2.4772e-05
#> [ CPUFloatType{4,4} ]