tensorly.tenalg.svd_interface

svd_interface(matrix, method='truncated_svd', n_eigenvecs=None, flip_sign=True, u_based_flip_sign=True, non_negative=None, mask=None, n_iter_mask_imputation=5, **kwargs)[source]

Dispatching function to various SVD algorithms, alongside additional properties such as resolving sign invariance, imputation, and non-negativity.

Parameters:
matrixtensor

A 2D tensor.

methodstr, default is ‘truncated_svd’

Function to use to compute the SVD, acceptable values in tensorly.SVD_FUNS or a callable.

n_eigenvecsint, optional, default is None

If specified, number of eigen[vectors-values] to return.

flip_signbool, optional, default is True

Whether to resolve the sign indeterminacy of SVD.

u_based_flip_signbool, optional, default is True

Whether the sign indeterminacy should be resolved using U (vs. V).

non_negativebool, optional, default is False

Whether to make the SVD results non-negative.

nn_typestr, default is ‘nndsvd’

Algorithm to use for converting U to be non-negative.

masktensor, default is None.

Array of booleans with the same shape as matrix. Should be 0 where the values are missing and 1 everywhere else. None if nothing is missing.

n_iter_mask_imputationint, default is 5

Number of repetitions to apply in missing value imputation.

**kwargsoptional

Arguments passed along to individual SVD algorithms.

Returns:
U2-D tensor, shape (matrix.shape[0], n_eigenvecs)

Contains the right singular vectors of matrix

S1-D tensor, shape (n_eigenvecs, )

Contains the singular values of matrix

V2-D tensor, shape (n_eigenvecs, matrix.shape[1])

Contains the left singular vectors of matrix