linalg_tensorinv | R Documentation |
torch_tensordot()
If m
is the product of the first ind
dimensions of A
and n
is the product of
the rest of the dimensions, this function expects m
and n
to be equal.
If this is the case, it computes a tensor X
such that
tensordot(A, X, ind)
is the identity matrix in dimension m
.
linalg_tensorinv(A, ind = 3L)
A |
(Tensor): tensor to invert. |
ind |
(int): index at which to compute the inverse of |
Supports input of float, double, cfloat and cdouble dtypes.
Consider using linalg_tensorsolve()
if possible for multiplying a tensor on the left
by the tensor inverse as linalg_tensorsolve(A, B) == torch_tensordot(linalg_tensorinv(A), B))
It is always prefered to use linalg_tensorsolve()
when possible, as it is faster and more
numerically stable than computing the pseudoinverse explicitly.
linalg_tensorsolve()
computes torch_tensordot(linalg_tensorinv(A), B))
.
Other linalg:
linalg_cholesky_ex()
,
linalg_cholesky()
,
linalg_det()
,
linalg_eigh()
,
linalg_eigvalsh()
,
linalg_eigvals()
,
linalg_eig()
,
linalg_householder_product()
,
linalg_inv_ex()
,
linalg_inv()
,
linalg_lstsq()
,
linalg_matrix_norm()
,
linalg_matrix_power()
,
linalg_matrix_rank()
,
linalg_multi_dot()
,
linalg_norm()
,
linalg_pinv()
,
linalg_qr()
,
linalg_slogdet()
,
linalg_solve_triangular()
,
linalg_solve()
,
linalg_svdvals()
,
linalg_svd()
,
linalg_tensorsolve()
,
linalg_vector_norm()
if (torch_is_installed()) {
A <- torch_eye(4 * 6)$reshape(c(4, 6, 8, 3))
Ainv <- linalg_tensorinv(A, ind = 3)
Ainv$shape
B <- torch_randn(4, 6)
torch_allclose(torch_tensordot(Ainv, B), linalg_tensorsolve(A, B))
A <- torch_randn(4, 4)
Atensorinv <- linalg_tensorinv(A, 2)
Ainv <- linalg_inv(A)
torch_allclose(Atensorinv, Ainv)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.