Addbmm
Source:R/gen-namespace-docs.R
, R/gen-namespace-examples.R
, R/gen-namespace.R
torch_addbmm.Rd
Addbmm
addbmm(input, batch1, batch2, *, beta=1, alpha=1, out=NULL) -> Tensor
Performs a batch matrix-matrix product of matrices stored
in batch1
and batch2
,
with a reduced add step (all matrix multiplications get accumulated
along the first dimension).
input
is added to the final result.
batch1
and batch2
must be 3-D tensors each containing the
same number of matrices.
If batch1
is a \((b \times n \times m)\) tensor, batch2
is a
\((b \times m \times p)\) tensor, input
must be
broadcastable with a \((n \times p)\) tensor
and out
will be a \((n \times p)\) tensor.
$$
out = \beta\ \mbox{input} + \alpha\ (\sum_{i=0}^{b-1} \mbox{batch1}_i \mathbin{@} \mbox{batch2}_i)
$$
For inputs of type FloatTensor
or DoubleTensor
, arguments beta
and alpha
must be real numbers, otherwise they should be integers.
Examples
if (torch_is_installed()) {
M = torch_randn(c(3, 5))
batch1 = torch_randn(c(10, 3, 4))
batch2 = torch_randn(c(10, 4, 5))
torch_addbmm(M, batch1, batch2)
}
#> torch_tensor
#> 0.6408 4.5084 8.0690 -12.0503 6.4947
#> 7.1883 7.5900 7.0608 1.1047 7.5638
#> 3.1867 -0.3468 -3.4107 8.6254 -6.1866
#> [ CPUFloatType{3,5} ]