Overview
GCPDecompositions — ModuleGeneralized CP Decomposition module. Provides approximate CP tensor decomposition with respect to general losses.
GCPDecompositions.gcp — Functiongcp(X::Array, r;
loss = GCPLosses.LeastSquares(),
constraints = default_constraints(loss),
algorithm = default_algorithm(X, r, loss, constraints),
init = default_init(X, r, loss, constraints, algorithm))Compute an approximate rank-r CP decomposition of the tensor X with respect to the loss function loss and return a CPD object.
Keyword arguments:
constraints: aTupleof constraints on the factor matricesU = (U[1],...,U[N]).algorithm: algorithm to use
Conventional CP corresponds to the default GCPLosses.LeastSquares() loss with the default of no constraints (i.e., constraints = ()).
If the LossFunctions.jl package is also loaded, loss can also be a loss function from that package. Check GCPDecompositions.LossFunctionsExt.SupportedLosses to see what losses are supported.
See also: CPD, GCPLosses, GCPConstraints, GCPAlgorithms.
GCPDecompositions.CPD — TypeCPDTensor decomposition type for the canonical polyadic decompositions (CPD) of a tensor (i.e., a multi-dimensional array) A. This is the return type of gcp(_), the corresponding tensor decomposition function.
If M::CPD is the decomposition object, the weights λ and the factor matrices U = (U[1],...,U[N]) can be obtained via M.λ and M.U, such that A = Σ_j λ[j] U[1][:,j] ∘ ⋯ ∘ U[N][:,j].
GCPDecompositions.ncomps — Functionncomps(M::CPD)Return the number of components in M.
See also: ndims, size.
GCPDecompositions.normalizecomps — Functionnormalizecomps(M::CPD, p::Real = 2)Normalize the components of M so that the columns of all its factor matrices all have p-norm equal to unity, i.e., norm(M.U[k][:, j], p) == 1 for all k ∈ 1:ndims(M) and j ∈ 1:ncomps(M). The excess weight is absorbed into M.λ. Norms equal to zero are ignored (i.e., treated as though they were equal to one).
The following keyword arguments can be used to modify this behavior:
dimsspecifies what to normalize (default:[:λ; 1:ndims(M)])distribute_tospecifies where to distribute the excess weight (default::λ)
Valid options for these arguments are the symbol :λ, an integer in 1:ndims(M), or a collection of these.
See also: normalizecomps!, norm.
GCPDecompositions.normalizecomps! — Functionnormalizecomps!(M::CPD, p::Real = 2)Normalize the components of M in-place so that the columns of all its factor matrices all have p-norm equal to unity, i.e., norm(M.U[k][:, j], p) == 1 for all k ∈ 1:ndims(M) and j ∈ 1:ncomps(M). The excess weight is absorbed into M.λ. Norms equal to zero are ignored (i.e., treated as though they were equal to one).
The following keyword arguments can be used to modify this behavior:
dimsspecifies what to normalize (default:[:λ; 1:ndims(M)])distribute_tospecifies where to distribute the excess weight (default::λ)
Valid options for these arguments are the symbol :λ, an integer in 1:ndims(M), or a collection of these.
See also: normalizecomps, norm.
GCPDecompositions.permutecomps — Functionpermutecomps(M::CPD, perm)Permute the components of M. perm is a vector or a tuple of length ncomps(M) specifying the permutation.
See also: permutecomps!.
GCPDecompositions.permutecomps! — Functionpermutecomps!(M::CPD, perm)Permute the components of M in-place. perm is a vector or a tuple of length ncomps(M) specifying the permutation.
See also: permutecomps.
GCPDecompositions.default_constraints — Functiondefault_constraints(loss)Return a default tuple of constraints for the loss function loss.
See also: gcp.
GCPDecompositions.default_algorithm — Functiondefault_algorithm(X, r, loss, constraints)Return a default algorithm for the data tensor X, rank r, loss function loss, and tuple of constraints constraints.
See also: gcp.
GCPDecompositions.default_init — Functiondefault_init([rng=default_rng()], X, r, loss, constraints, algorithm)Return a default initialization for the data tensor X, rank r, loss function loss, tuple of constraints constraints, and algorithm algorithm, using the random number generator rng if needed.
See also: gcp.