Baddbmm

torch_baddbmm(self, batch1, batch2, beta = 1L, alpha = 1L)

Arguments

self

(Tensor) the tensor to be added

batch1

(Tensor) the first batch of matrices to be multiplied

batch2

(Tensor) the second batch of matrices to be multiplied

beta

(Number, optional) multiplier for input (\(\beta\))

alpha

(Number, optional) multiplier for \(\mbox{batch1} \mathbin{@} \mbox{batch2}\) (\(\alpha\))

baddbmm(input, batch1, batch2, *, beta=1, alpha=1, out=NULL) -> Tensor

Performs a batch matrix-matrix product of matrices in batch1 and batch2. 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, then input must be broadcastable with a \((b \times n \times p)\) tensor and out will be a \((b \times n \times p)\) tensor. Both alpha and beta mean the same as the scaling factors used in torch_addbmm.

$$ \mbox{out}_i = \beta\ \mbox{input}_i + \alpha\ (\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(10, 3, 5)) batch1 = torch_randn(c(10, 3, 4)) batch2 = torch_randn(c(10, 4, 5)) torch_baddbmm(M, batch1, batch2) }
#> torch_tensor #> (1,.,.) = #> -1.7024 0.9182 -1.9423 0.3988 2.0035 #> 2.5695 -0.4139 2.7159 0.0866 -3.2092 #> 1.4565 0.2570 -1.1509 -1.4427 -0.8940 #> #> (2,.,.) = #> -5.6410 4.3985 -3.8984 2.8174 0.8102 #> -3.8068 1.4878 0.0058 0.2715 0.6891 #> 2.5995 1.4655 -1.5567 2.8200 -2.5535 #> #> (3,.,.) = #> 1.2924 -1.1599 2.4611 -1.9251 1.0187 #> 2.2823 -0.7280 -0.5414 1.7261 1.5052 #> -3.7839 3.6498 -1.3524 3.0182 0.7268 #> #> (4,.,.) = #> -3.4666 1.5670 3.0541 0.5957 -0.6245 #> -4.1030 3.3020 5.3213 2.0831 -2.1845 #> -3.7433 -1.2357 1.5749 -4.5007 -0.0022 #> #> (5,.,.) = #> 0.5363 -2.1345 1.4722 -4.0148 -3.1078 #> 0.4169 0.8655 -0.4123 1.1957 4.0190 #> 0.6982 0.3890 -2.4045 0.5699 -2.2284 #> #> (6,.,.) = #> -3.8209 -0.6885 2.3253 1.8102 -1.0631 #> 1.2641 0.5953 0.3469 2.4249 2.1432 #> -1.5271 1.0830 0.1805 -0.4257 0.3477 #> #> ... [the output was truncated (use n=-1 to disable)] #> [ CPUFloatType{10,3,5} ]