Overview

Work-in-progress

This page of the docs is still a work-in-progress. Check back later!

GCPDecompositionsModule

Generalized CP Decomposition module. Provides approximate CP tensor decomposition with respect to general losses.

source
GCPDecompositions.gcpFunction
gcp(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 : a Tuple of constraints on the factor matrices U = (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.

source
GCPDecompositions.CPDType
CPD

Tensor 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].

source
GCPDecompositions.normalizecompsFunction
normalizecomps(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:

  • dims specifies what to normalize (default: [:λ; 1:ndims(M)])
  • distribute_to specifies 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.

source
GCPDecompositions.normalizecomps!Function
normalizecomps!(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:

  • dims specifies what to normalize (default: [:λ; 1:ndims(M)])
  • distribute_to specifies 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.

source
GCPDecompositions.permutecompsFunction
permutecomps(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!.

source
GCPDecompositions.permutecomps!Function
permutecomps!(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.

source
GCPDecompositions.default_algorithmFunction
default_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.

source
GCPDecompositions.default_initFunction
default_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.

source