RDFTensor (version 1.3)

cp_als: Compute a CP decomposition using an alternating least-squares algorithm(als)

Description

computes an estimate of the best rank-R PARAFAC model of a tensor X using an alternating least-squares algorithm Translated from cp_als.m : MATLAB Tensor Toolbox

Usage

cp_als(X, R, opts = list())

Arguments

X

is a sparse tensor (a LIST containing subs, vals and size)

R

The rank of the factorization

opts

a list containing the options for the algorithm like maxiters:maximum iterations, tol:tolerance .. etc.

Value

P

the factorization of X as a LIST representing Kruskal Tensor (lambda and u)

Uinit

the initial solution

iters

number of iterations.

fit

fraction explained by the model.

References

-Brett W. Bader, Tamara G. Kolda and others. MATLAB Tensor Toolbox, Version [v3.0]. Available online at https://www.tensortoolbox.org, 2015.

See Also

cp_apr serial_parCube rescal cp_nmu

Examples

Run this code
# NOT RUN {
subs=matrix(c(5,1,1,
              3,1,2,
              1,1,3,
              2,1,3,
              4,1,3,
              6,1,3,
              1,1,4,
              2,1,4,
              4,1,4,
              6,1,4,
              1,2,1,
              3,2,1,
              5,2,1),byrow=TRUE,ncol=3)

X=list(subs=subs,vals=rep(1,nrow(subs)),size=c(6,2,4))
set.seed(123)
P1=cp_als(X,2)

# }

Run the code above in your browser using DataLab