tensap.approximation.tensor_approximation.tensor_learning package

Submodules

tensap.approximation.tensor_approximation.tensor_learning.canonical_tensor_learning module

Module canonical_tensor_learning.

class tensap.approximation.tensor_approximation.tensor_learning.canonical_tensor_learning.CanonicalTensorLearning(order, *args)

Bases: tensap.approximation.tensor_approximation.tensor_learning.tensor_learning.TensorLearning

Class CanonicalTensorLearning.

See also tensap.TensorLearning.

Attributes
orderint

The order of the tensor.

Methods

adapt_tree(f, cv_error, test_error, output, …)

Tree adaptation algorithm.

adaptation_display(f, *args)

Display during the adaptation.

final_display(f)

Display at the end of the computation.

initial_guess_new_rank(s_local, f, *args)

Computation of the initial guess with the new selected rank.

initialize()

Initialization of the learning algorithm.

local_solver()

Extraction of the solver for the adaptive algorithm

new_rank_selection(f)

Selection of a new rank in the adaptive algorithm.

pre_processing(f)

Initialization of the alternating minimization algorithm.

prepare_alternating_minimization_system(f, mu)

Preparation of the alternating minimization algorithm.

randomize_exploration_strategy()

Randomization of the exploration strategy.

set_parameter(f, mu, coef)

Update of the parameter mu of the tensor f.

solve(*args)

Solver for the learning problem with tensor formats.

stagnation_criterion(f, f0)

Computation of the stagnation criterion.

linear_model

risk_estimation

adaptation_display(f, *args)

Display during the adaptation.

Parameters
ftensap.FunctionalTensor

The current approximation.

enriched_nodesnumpy.ndarray

The enriched parameters.

final_display(f)

Display at the end of the computation.

Parameters
ftensap.FunctionalTensor

The current approximation.

Returns
None.
initial_guess_new_rank(s_local, f, *args)

Computation of the initial guess with the new selected rank.

Parameters
s_localtensap.TensorLearning

The local solver.

ftensap.FunctionalTensor

The current approximation.

new_ranknumpy.ndarray

The new tensor rank.

Returns
s_localtensap.TensorLearning

The local solver with the initial guess in s_local.initial_guess.

initialize()

Initialization of the learning algorithm.

Returns
tensap.TensorLearning

The TensorLearning object.

ftensap.FunctionalTensor

The initialization of the solver.

local_solver()

Extraction of the solver for the adaptive algorithm

Returns
s_localtensap.TensorLearning

The local solver.

new_rank_selection(f)

Selection of a new rank in the adaptive algorithm.

Parameters
ftensap.FunctionalTensor

The current approximation.

Returns
new_ranknumpy.ndarray

The new tensor rank.

enriched_nodesnumpy.ndarray

The enriched parameters.

tensor_for_initializationtensap.Tensor

A tensor used for the initialization of the next iteration.

pre_processing(f)

Initialization of the alternating minimization algorithm.

Parameters
ftensap.Tensor

The current tensor approximation.

Returns
tensap.TensorLearning

The TensorLearning object.

ftensap.Tensor

The pre-processed tensor approximation.

prepare_alternating_minimization_system(f, mu)

Preparation of the alternating minimization algorithm.

Parameters
ftensap.FunctionalTensor

The current approximation.

muint

The number of the parameter to be optimized.

Returns
tensap.TensorLearning

The TensorLearning object.

Anumpy.ndarray

The matricized partial evaluation of f.

bnumpy.ndarray

The target training data.

ftensap.FunctionalTensor

The current approximation.

randomize_exploration_strategy()

Randomization of the exploration strategy.

Returns
alpha_listnumpy.ndarray

The randomized exploration strategy.

set_parameter(f, mu, coef)

Update of the parameter mu of the tensor f.

Parameters
ftensap.FunctionalTensor

The current approximation.

muint

The number of the optimized parameter.

coefnumpy.ndarray

The new value of the parameter mu of f.

Returns
ftensap.FunctionalTensor

The updated approximation.

stagnation_criterion(f, f0)

Computation of the stagnation criterion.

Parameters
ftensap.FunctionalTensor

The current approximation.

f0tensap.FunctionalTensor

The previous approximation.

Returns
stagnationfloat

The value of the stagnation criterion.

tensap.approximation.tensor_approximation.tensor_learning.tensor_learning module

Module tensor_learning.

class tensap.approximation.tensor_approximation.tensor_learning.tensor_learning.TensorLearning(loss)

Bases: tensap.approximation.learning.learning.Learning

Class TensorLearning.

See also tensap.Learning.

Attributes
orderint

Order of the tensor.

baseslist or numpy.ndarray

The functional bases used for by the approximation.

bases_evallist or numpy.ndarray

The evaluations of the bases on the training data.

bases_eval_testlist or numpy.ndarray

The evaluations of the bases on the test data.

algorithmstr

The choice of algorithm.

initialization_typestr

The type of initialization.

initial_guesstensap.Tensor

An initial guess for the solver.

tree_adaptationbool

Boolean indicating if tree adaptation is to be performed.

tree_adaptation_optionsdict

Options for the tree adaptation.

rank_adaptationbool

Boolean indicating if rank adaptation is to be performed.

rank_adaptation_optionsdict

Options for the rank adaptation.

tolerancedict

Tolerances for the solver.

linear_model_learning_parametersdict

Parameters for the linear solvers.

alternating_minimization_parametersdict

Parameters for the alternating minimization.

bases_adaptation_pathlist or numpy.ndarray

Paths for each basis for the basis adaptation.

store_iteratesbool

Boolean indicating if the iterates are to be stored.

rankint or list or numpy.ndarray

The rank of the expected approximation.

output_dimensionint

The dimension of the outputs of the function to be approximated.

_number_of_parametersint

The number of parameters of the approximation.

_exploration_strategynumpy.ndarray

The exploration strategy.

_warningsdict

Dictionnary containing the state of some warnings to be displayed.

Methods

adapt_tree(f, cv_error, test_error, output, …)

Tree adaptation algorithm.

adaptation_display(f, enriched_nodes)

Display during the adaptation.

final_display(f)

Display at the end of the computation.

initial_guess_new_rank(s_local, f, new_rank)

Computation of the initial guess with the new selected rank.

initialize()

Initialization of the learning algorithm.

local_solver()

Extraction of the solver for the adaptive algorithm

new_rank_selection(f)

Selection of a new rank in the adaptive algorithm.

pre_processing(f)

Initialization of the alternating minimization algorithm.

prepare_alternating_minimization_system(f, mu)

Preparation of the alternating minimization algorithm.

randomize_exploration_strategy()

Randomization of the exploration strategy.

set_parameter(f, mu, coef)

Update of the parameter mu of the tensor f.

solve(*args)

Solver for the learning problem with tensor formats.

stagnation_criterion(f, f0)

Computation of the stagnation criterion.

linear_model

risk_estimation

adapt_tree(f, cv_error, test_error, output, *args)

Tree adaptation algorithm.

Parameters
ftensap.Tensor

The current tensor approximation.

cv_errorfloat

The current cross-validation error.

test_errorfloat

The current test error.

outputdict

The outputs of the solver.

argstuple

Additional parameters.

Returns
tensap.TensorLearning

The TensorLearning object.

ftensap.Tensor

The current tensor approximation, perhaps with an adapted tree.

outputdict

The outputs of the solver.

abstract adaptation_display(f, enriched_nodes)

Display during the adaptation.

Parameters
ftensap.FunctionalTensor

The current approximation.

enriched_nodesnumpy.ndarray

The enriched parameters.

abstract final_display(f)

Display at the end of the computation.

Parameters
ftensap.FunctionalTensor

The current approximation.

Returns
None.
abstract initial_guess_new_rank(s_local, f, new_rank)

Computation of the initial guess with the new selected rank.

Parameters
s_localtensap.TensorLearning

The local solver.

ftensap.FunctionalTensor

The current approximation.

new_ranknumpy.ndarray

The new tensor rank.

Returns
s_localtensap.TensorLearning

The local solver with the initial guess in s_local.initial_guess.

abstract initialize()

Initialization of the learning algorithm.

Returns
tensap.TensorLearning

The TensorLearning object.

ftensap.FunctionalTensor

The initialization of the solver.

abstract local_solver()

Extraction of the solver for the adaptive algorithm

Returns
s_localtensap.TensorLearning

The local solver.

abstract new_rank_selection(f)

Selection of a new rank in the adaptive algorithm.

Parameters
ftensap.FunctionalTensor

The current approximation.

Returns
new_ranknumpy.ndarray

The new tensor rank.

enriched_nodesnumpy.ndarray

The enriched parameters.

tensor_for_initializationtensap.Tensor

A tensor used for the initialization of the next iteration.

abstract pre_processing(f)

Initialization of the alternating minimization algorithm.

Parameters
ftensap.Tensor

The current tensor approximation.

Returns
tensap.TensorLearning

The TensorLearning object.

ftensap.Tensor

The pre-processed tensor approximation.

abstract prepare_alternating_minimization_system(f, mu)

Preparation of the alternating minimization algorithm.

Parameters
ftensap.FunctionalTensor

The current approximation.

muint

The number of the parameter to be optimized.

Returns
tensap.TensorLearning

The TensorLearning object.

Anumpy.ndarray

The matricized partial evaluation of f.

bnumpy.ndarray

The target training data.

ftensap.FunctionalTensor

The current approximation.

abstract randomize_exploration_strategy()

Randomization of the exploration strategy.

Returns
alpha_listnumpy.ndarray

The randomized exploration strategy.

abstract set_parameter(f, mu, coef)

Update of the parameter mu of the tensor f.

Parameters
ftensap.FunctionalTensor

The current approximation.

muint

The number of the optimized parameter.

coefnumpy.ndarray

The new value of the parameter mu of f.

Returns
ftensap.FunctionalTensor

The updated approximation.

solve(*args)

Solver for the learning problem with tensor formats.

Parameters
*argsmisc

Additional arguments, if needed.

Returns
ftensap.FunctionalTensor

The learned approximation.

outputdict

The outputs of the solver.

Raises
NotImplementedError

If the required solver is not implemented.

ValueError

If the required data is not provided.

abstract stagnation_criterion(f, f0)

Computation of the stagnation criterion.

Parameters
ftensap.FunctionalTensor

The current approximation.

f0tensap.FunctionalTensor

The previous approximation.

Returns
stagnationfloat

The value of the stagnation criterion.

tensap.approximation.tensor_approximation.tensor_learning.tree_based_tensor_learning module

Module tree_based_tensor_learning.

class tensap.approximation.tensor_approximation.tensor_learning.tree_based_tensor_learning.TreeBasedTensorLearning(tree, is_active_node, *args)

Bases: tensap.approximation.tensor_approximation.tensor_learning.tensor_learning.TensorLearning

Class TreeBasedTensorLearning.

See also tensap.TensorLearning.

Attributes
treetensap.DimensionTree

The dimension tree of the tree-based tensor.

is_active_nodelist or numpy.ndarray

Booleans indicating if each node is active.

Methods

adapt_tree(f, cv_error, test_error, output, …)

Tree adaptation algorithm.

adaptation_display(f, enriched_nodes)

Display during the adaptation.

canonical_correction(f, rank)

Rank-r canonical correction.

canonical_initialization(rank)

Rank-r canonical initialization.

create_basis_adaptation_path(ranks, alpha)

Creation of the basis adaptation path.

enriched_edges_to_ranks_random(f, new_rank)

Enrichment of the ranks of specified edges of the tensor f using random additions for each child / parent couple of the enriched edges.

final_display(f)

Display at the end of the computation.

initial_guess_new_rank(s_local, f, new_rank)

Computation of the initial guess with the new selected rank.

initialize()

Initialization of the learning algorithm.

local_solver()

Extraction of the solver for the adaptive algorithm

make_ranks_admissible(f, rank)

Adjustment of the ranks to make the associated tree-based tensor f rank-admissible, by enriching new edges associated with nodes of the tree until all the rank admissibility conditions are met.

new_rank_selection(f)

Selection of a new rank in the adaptive algorithm.

pre_processing(f)

Initialization of the alternating minimization algorithm.

prepare_alternating_minimization_system(f, mu)

Preparation of the alternating minimization algorithm.

randomize_exploration_strategy()

Randomization of the exploration strategy.

rank_one_correction(f)

Rank one correction.

set_parameter(f, mu, coef)

Update of the parameter mu of the tensor f.

solve(*args)

Solver for the learning problem with tensor formats.

stagnation_criterion(f, f0)

Computation of the stagnation criterion.

tensor_train(order, *args)

Call of the constructor of the class TreeBasedTensorLearning, with a tree and active nodes corresponding to the Tensor-Train format in dimension order.

tensor_train_tucker(order, *args)

Call of the constructor of the class TreeBasedTensorLearning, with a tree and active nodes corresponding to the Tensor-Train Tucker format in dimension order.

unique_tol(inp, tol)

Unique values within tolerance, with sorted output.

create_basis_adaptation_path_dmrg

create_basis_adaptation_path_dmrg_low_rank

linear_model

risk_estimation

adapt_tree(f, cv_error, test_error, output, *args)

Tree adaptation algorithm.

Parameters
ftensap.Tensor

The current tensor approximation.

cv_errorfloat

The current cross-validation error.

test_errorfloat

The current test error.

outputdict

The outputs of the solver.

argstuple

Additional parameters.

Returns
tensap.TensorLearning

The TensorLearning object.

ftensap.Tensor

The current tensor approximation, perhaps with an adapted tree.

outputdict

The outputs of the solver.

adaptation_display(f, enriched_nodes)

Display during the adaptation.

Parameters
ftensap.FunctionalTensor

The current approximation.

enriched_nodesnumpy.ndarray

The enriched parameters.

canonical_correction(f, rank)

Rank-r canonical correction.

Parameters
ftensap.FunctionalTensor or None

The current approximation.

rankint

The rank of the canonical correction.

Returns
ftensap.FunctionalTensor

The corrected approximation.

Raises
NotImplementedError

If the method is not implemented.

canonical_initialization(rank)

Rank-r canonical initialization.

Parameters
rankint

The rank of the canonical initialization.

Returns
tensap.TreeBasedTensor

The rank-r canonical initialization..

create_basis_adaptation_path(ranks, alpha)

Creation of the basis adaptation path.

Parameters
ranklist or numpy.ndarray

The alpha-ranks of the current approximation.

alphaint

The current node.

Returns
pathnumpy.ndarray

The basis adaptation path.

create_basis_adaptation_path_dmrg(ranks, alpha)
create_basis_adaptation_path_dmrg_low_rank(ranks, alpha)
static enriched_edges_to_ranks_random(f, new_rank)

Enrichment of the ranks of specified edges of the tensor f using random additions for each child / parent couple of the enriched edges.

Parameters
ftensap.TreeBasedTensor

The tree-based tensor to enrich.

new_ranklist or numpy.ndarray

The new tree-based rank.

Returns
ftensap.TreeBasedTensor

The enriched tree-based tensor.

final_display(f)

Display at the end of the computation.

Parameters
ftensap.FunctionalTensor

The current approximation.

Returns
None.
initial_guess_new_rank(s_local, f, new_rank)

Computation of the initial guess with the new selected rank.

Parameters
s_localtensap.TensorLearning

The local solver.

ftensap.FunctionalTensor

The current approximation.

new_ranknumpy.ndarray

The new tensor rank.

Returns
s_localtensap.TensorLearning

The local solver with the initial guess in s_local.initial_guess.

initialize()

Initialization of the learning algorithm.

Returns
tensap.TensorLearning

The TensorLearning object.

ftensap.FunctionalTensor

The initialization of the solver.

local_solver()

Extraction of the solver for the adaptive algorithm

Returns
s_localtensap.TensorLearning

The local solver.

static make_ranks_admissible(f, rank)

Adjustment of the ranks to make the associated tree-based tensor f rank-admissible, by enriching new edges associated with nodes of the tree until all the rank admissibility conditions are met.

Parameters
ftensap.TreeBasedTensor

The current approximation in tree-based tensor format.

ranknumpy.ndarray

The proposed tree-based rank.

Returns
ranknumpy.ndarray

The admissible tree-based rank (if possible).

dnumpy.ndarray

The enriched nodes.

new_rank_selection(f)

Selection of a new rank in the adaptive algorithm.

Parameters
ftensap.FunctionalTensor

The current approximation.

Returns
new_ranknumpy.ndarray

The new tensor rank.

enriched_nodesnumpy.ndarray

The enriched parameters.

tensor_for_initializationtensap.Tensor

A tensor used for the initialization of the next iteration.

pre_processing(f)

Initialization of the alternating minimization algorithm.

Parameters
ftensap.Tensor

The current tensor approximation.

Returns
tensap.TensorLearning

The TensorLearning object.

ftensap.Tensor

The pre-processed tensor approximation.

prepare_alternating_minimization_system(f, mu)

Preparation of the alternating minimization algorithm.

Parameters
ftensap.FunctionalTensor

The current approximation.

muint

The number of the parameter to be optimized.

Returns
tensap.TensorLearning

The TensorLearning object.

Anumpy.ndarray

The matricized partial evaluation of f.

bnumpy.ndarray

The target training data.

ftensap.FunctionalTensor

The current approximation.

randomize_exploration_strategy()

Randomization of the exploration strategy.

Returns
alpha_listnumpy.ndarray

The randomized exploration strategy.

rank_one_correction(f)

Rank one correction.

Parameters
ftensap.FunctionalTensor or None

The current approximation.

Returns
ftensap.FunctionalTensor

The corrected approximation.

Raises
NotImplementedError

If the method is not implemented.

set_parameter(f, mu, coef)

Update of the parameter mu of the tensor f.

Parameters
ftensap.FunctionalTensor

The current approximation.

muint

The number of the optimized parameter.

coefnumpy.ndarray

The new value of the parameter mu of f.

Returns
ftensap.FunctionalTensor

The updated approximation.

stagnation_criterion(f, f0)

Computation of the stagnation criterion.

Parameters
ftensap.FunctionalTensor

The current approximation.

f0tensap.FunctionalTensor

The previous approximation.

Returns
stagnationfloat

The value of the stagnation criterion.

static tensor_train(order, *args)

Call of the constructor of the class TreeBasedTensorLearning, with a tree and active nodes corresponding to the Tensor-Train format in dimension order.

See also TreeBasedTensorLearning.

Parameters
orderint

The order of the tensor.

*argstuple

Additional parameters (see the constructor of TreeBasedTensorLearning).

Returns
TreeBasedTensorLearning

The solver with a tree and active nodes associated with the Tensor-Train format.

static tensor_train_tucker(order, *args)

Call of the constructor of the class TreeBasedTensorLearning, with a tree and active nodes corresponding to the Tensor-Train Tucker format in dimension order.

See also TreeBasedTensorLearning.

Parameters
orderint

The order of the tensor.

*argstuple

Additional parameters (see the constructor of TreeBasedTensorLearning).

Returns
TreeBasedTensorLearning

The solver with a tree and active nodes associated with the Tensor-Train Tucker format.

static unique_tol(inp, tol)

Unique values within tolerance, with sorted output.

Parameters
inplist of numpy.ndarray

The values to be checked.

tolfloat

The tolerance defining the uniqueness.

Returns
boutnumpy.ndarray

The unique values of inp, within the tolerance tol.

Module contents