TensorDecompositions.CANDECOMP_methods
— ConstantCodes of implemented CANDECOMP methods.
TensorDecompositions.ArrayPool
— TypeHelps to maintain the pool of reusable arrays of different sizes and reduce the burden on garbage collection.
TensorDecompositions.CANDECOMP
— TypeCanonical polyadic N-mode tensor decomposition (CANDECOMP/PARAFAC).
TensorDecompositions.CUR
— TypeCUR (columns-U-rows) 3-tensor decomposition.
TensorDecompositions.PARAFAC2
— TypeParallel Factor Analysis (PARAFAC) decomposition
TensorDecompositions.SPNNTuckerHelper
— TypeHelper object for spnntucker().
TensorDecompositions.SPNNTuckerState
— TypeState of sparse (semi-)nonnegative Tucker decomposition
TensorDecompositions.SparseArray
— TypeSparse N-mode array.
vals
contains all (L
) non-zero elements. pos
is N
xL
matrix of non-zero elements indices. dims
is NTuple
of array dimensions.
TensorDecompositions.SparseArray
— MethodConvert dense N-dimensional array into N-dimensional a SparseArray
.
TensorDecompositions.TensorDecomposition
— TypeAbstract decomposition of N-mode tensor.
TensorDecompositions.Tucker
— TypeTucker decomposition of a N-mode tensor.
LinearAlgebra.rank
— MethodReturns CANDECOMP rank.
TensorDecompositions._candecomp
— MethodComputes CANDECOMP by ALS (Alternating Least Squares) method.
TensorDecompositions._candecomp
— MethodComputes CANDECOMP by SGSD (Simultaneous Generalized Schur Decomposition) method.
TensorDecompositions._candecomp
— MethodStub for non-implemented CANDECOMP algorithms.
TensorDecompositions._check_tensor
— MethodChecks the validity of the core tensor dimensions, where core tensor is r^N
hypercube.
TensorDecompositions._check_tensor
— MethodChecks the validity of the core tensor dimensions.
TensorDecompositions._col_unfold
— MethodUnfolds the tensor into matrix such that the specified mode becomes matrix column.
TensorDecompositions._random_factors
— MethodGenerates random factor matrices for Tucker/CANDECOMP decompositions if core tensor is r^N
hypercube.
Returns:
- a vector of
N
(orig[n], r)-sized matrices
TensorDecompositions._random_factors
— MethodGenerates random factor matrices for Tucker/CANDECOMP etc decompositions.
orig_dims
original tensor dimensionscore_dims
core tensor dimensions
Returns:
- a vector of
N
(orig[n], core[n])-sized matrices
TensorDecompositions._row_unfold
— MethodUnfolds the tensor into matrix such that the specified mode becomes matrix row.
TensorDecompositions._unfold
— MethodUnfolds the tensor into matrix, such that the specified group of modes becomes matrix rows and the other one becomes columns.
row_modes
vector of modes to be unfolded as rowscol_modes
vector of modes to be unfolded as columns
TensorDecompositions.acquire!
— MethodGets an array of specific size from the pool. The returned array should be returned back to the pool using release!()
.
TensorDecompositions.candecomp
— MethodCalculates canonical polyadic tensor decomposition (CANDECOMP/PARAFAC).
Returns: CANDECOMP
object
TensorDecompositions.compose!
— MethodRe-composes the tensor from CANDECOMP decomposition.
TensorDecompositions.compose
— MethodComposes a full tensor from Tucker decomposition.
TensorDecompositions.core
— MethodReturns the core tensor of Tucker decomposition.
TensorDecompositions.factors
— MethodReturns the factor matrices of Tucker decomposition.
TensorDecompositions.hosvd
— MethodHigh-order singular value decomposition (HO-SVD).
TensorDecompositions.khatrirao!
— Methodkhatrirao!(dest::AbstractMatrix{T}, mtxs::NTuple{N, <:AbstractMatrix{T}})
In-place Khatri-Rao matrices product (column-wise Kronecker product) calculation.
TensorDecompositions.khatrirao
— Methodkhatrirao(mtxs::NTuple{N, <:AbstractMatrix{T}})
Calculates Khatri-Rao product of a sequence of matrices (column-wise Kronecker product).
TensorDecompositions.nncp
— MethodNon-negative CANDECOMP tensor decomposition.
TensorDecompositions.parafac2
— MethodPARAFAC2 model
TensorDecompositions.rel_residue
— MethodReturns relative tensor decomposition error, NaN if not available.
TensorDecompositions.rel_residue
— MethodReturns relative error between the re-composed and the original tensors.
TensorDecompositions.rel_residue
— MethodReturns relative error between re-composed and the original tensor.
TensorDecompositions.release!
— MethodReleases an array returned by acquire!()
back into the pool.
TensorDecompositions.rescale!
— MethodScale the factors and core of the initial decomposition. Each decompositon component is scaled proportional to the number of its elements. After scaling, |decomp|=s
TensorDecompositions.spnntucker
— MethodSparse (semi-)nonnegative Tucker decomposition
Decomposes nonnegative tensor tnsr
into optionally nonnegative core
tensor and sparse nonnegative factor matrices factors
.
tnsr
nonnegativeN
-mode tensor to decomposecore_dims
size of a core densorcore_nonneg
if true, the output core tensor is nonnegativetol
the target error of decomposition relative to the Frobenius norm oftnsr
max_iter
maximum number of iterations if error stays abovetol
max_time
max running timelambdas
N+1
vector of non-negative sparsity regularizer coefficients for the factor matrices and the core tensorLmin
lower bound for Lipschitz constant for the gradients of the residual error eqn{l(Z,U) = fnorm(tnsr - ttl(Z, U))by
Zand each
U`rw
controls the extrapolation weightbounds
N+1
vector of the maximal absolute values allows for the elements of core tensor and factor matrices (effective only if the regularization is disabled)ini_decomp
initial decomposition, if equals to:hosvd
,hosvd()
is used to generate the starting decomposition, ifnothing
, a random decomposition is usedverbose
more output algorithm progress
Returns:
Tucker
decomposition object with additional properties:
* `:converged` method convergence indicator
* `:rel_residue` the Frobenius norm of the residual error `l(Z,U)` plus regularization penalty (if any)
* `:niter` number of iterations
* `:nredo` number of times `core` and `factor` were recalculated to avoid the increase in objective function
* `:iter_diag` convergence info for each iteration, see `SPNNTuckerState`
The function uses the alternating proximal gradient method to solve the following optimization problem: deqn{min 0.5 |tnsr - Z times1 U1 ldots timesK UK |{F^2} + sum{n=1}^{K} lambdan |Un|1 + lambda{K+1} |Z|1, ;text{where; Z geq 0, Ui geq 0.} If core_nonneg
is FALSE
, core tensor Z
is allowed to have negative elements and eqn{z{i,j}=max(0,z{i,j}-lambda{K+1}/L{K+1}}) rule is replaced by eqn{z{i,j}=sign(z{i,j})max(0,|z{i,j}|-lambda{K+1}/L_{K+1})}. The method stops if either the relative improvement of the error is below the tolerance tol
for 3 consequitive iterations or both the relative error improvement and relative error (wrt the tnsr
norm) are below the tolerance. Otherwise it stops if the maximal number of iterations or the time limit were reached.
The implementation is based on ntds_fapg() MATLAB code by Yangyang Xu and Wotao Yin.
See Y. Xu, "Alternating proximal gradient method for sparse nonnegative Tucker decomposition", Math. Prog. Comp., 7, 39-70, 2015. See http://www.caam.rice.edu/~optimization/bcu/`
TensorDecompositions.sshopm
— MethodSS-HOPM (Shifted Symmetric Higher-order Power Method) for computing tensor eigenpars.
TensorDecompositions.tensorcontractmatrices
— FunctionContract N-mode tensor and M matrices.
tensor
tensor to contractmatrices
matrices to contractmodes
corresponding modes of matrices to contracttranspose
if true, matrices are contracted along their columns
TensorDecompositions.tensorcontractmatrices!
— MethodContract N-mode tensor and M matrices.
dest
array to hold the resultsrc
source tensor to contractmatrices
matrices to contractmodes
corresponding modes of matrices to contracttranspose
if true, matrices are contracted along their columns
TensorDecompositions.tensorcur3
— FunctionCalculates CUR decomposition for 3-mode tensors.