
Last chance! 50% off unlimited learning
Sale ends in
Svd
(Tensor) the input tensor of size *
is zero or more batch dimensions consisting of
(bool, optional) controls the shape of returned U
and V
(bool, optional) option whether to compute U
and V
or not
(tuple, optional) the output tuple of tensors
This function returns a namedtuple (U, S, V)
which is the singular value
decomposition of a input real matrix or batches of real matrices input
such that
If some
is True
(default), the method returns the reduced singular value decomposition
i.e., if the last two dimensions of input
are m
and n
, then the returned
U
and V
matrices will contain only
If compute_uv
is False
, the returned U
and V
matrices will be zero matrices
of shape some
will be ignored here.
# NOT RUN {
if (torch_is_installed()) {
a = torch_randn(c(5, 3))
a
out = torch_svd(a)
u = out[[1]]
s = out[[2]]
v = out[[3]]
torch_dist(a, torch_mm(torch_mm(u, torch_diag(s)), v$t()))
a_big = torch_randn(c(7, 5, 3))
out = torch_svd(a_big)
u = out[[1]]
s = out[[2]]
v = out[[3]]
torch_dist(a_big, torch_matmul(torch_matmul(u, torch_diag_embed(s)), v$transpose(-2, -1)))
}
# }
Run the code above in your browser using DataLab