Unconstrained CP Tensor Decomposition by Alternating Least Squares (ALS)

tensortools.cp_als(X, rank, random_state=None, init='randn', **options)

Fits CP Decomposition using the Alternating Least Squares (ALS).

Parameters:
  • X ((I_1, .., I_N) array_like) – A real array with X.ndim >= 3.
  • rank (integer) – The rank sets the number of components to be computed.
  • random_state (integer, RandomState, or None, optional (default None)) – If integer, sets the seed of the random number generator; If RandomState instance, random_state is the random number generator; If None, use the RandomState instance used by numpy.random.
  • init (str, or KTensor, optional (default 'randn').) – Specifies initial guess for KTensor factor matrices. If 'randn', Gaussian random numbers are used to initialize. If 'rand', uniform random numbers are used to initialize. If KTensor instance, a copy is made to initialize the optimization.
  • options (dict, specifying fitting options.) –
    tol : float, optional (default tol=1E-5)
    Stopping tolerance for reconstruction error.
    max_iter : integer, optional (default max_iter = 500)
    Maximum number of iterations to perform before exiting.
    min_iter : integer, optional (default min_iter = 1)
    Minimum number of iterations to perform before exiting.
    max_time : integer, optional (default max_time = np.inf)
    Maximum computational time before exiting.
    verbose : bool {'True', 'False'}, optional (default verbose=True)
    Display progress.
Returns:

result – Object which holds the fitted results. It provides the factor matrices in form of a KTensor, result.factors.

Return type:

FitResult instance

Notes

This implemenation uses the Alternating Least Squares Method.

References

Kolda, T. G. & Bader, B. W. “Tensor Decompositions and Applications.” SIAM Rev. 51 (2009): 455-500 http://epubs.siam.org/doi/pdf/10.1137/07070111X

Comon, Pierre & Xavier Luciani & Andre De Almeida. “Tensor decompositions, alternating least squares and other tales.” Journal of chemometrics 23 (2009): 393-405. http://onlinelibrary.wiley.com/doi/10.1002/cem.1236/abstract

Examples

` import tensortools as tt I, J, K, R = 20, 20, 20, 4 X = tt.randn_tensor(I, J, K, rank=R) tt.cp_als(X, rank=R) `