TransportMaps.Diagnostics.Validators

Module Contents

Classes

KLMinimizationValidator

Base object for every object in the module.

SampleAverageApproximationKLMinimizationValidator

Base object for every object in the module.

GradientBootstrapKLMinimizationValidator

Bootstrap the gradient to check whether cost function is flat independently of the sample.

DimensionAdaptiveSparseGridKLMinimizationValidator

Base object for every object in the module.

class TransportMaps.Diagnostics.Validators.KLMinimizationValidator(eps, cost_function=no_cost_function, max_cost=np.inf, max_nsamps=np.inf, stop_on_fcast=False)[source]

Bases: TransportMaps.ObjectBase.TMO

Base object for every object in the module.

This object provides functions for storage and parallelization.

pre_solve(base_distribution, target_distribution, transport_map, validation_params)[source]

Implements a routine to be initialize variables before the solving stage.

This function should initialize quantities that are needed for a particular validator.

post_solve(base_distribution, target_distribution, transport_map, validation_params)[source]

Implements a routine to be make sure the variables set in presolve are in the correct state post exiting the solving stage.

Since, in principle, algorithms can be stopped and re-started, this allows variables to be cleaned up when not needed.

solve_to_tolerance(transport_map, base_distribution, target_distribution, solve_params, mpi_pool=None)[source]
print_info(err, target_err, cost, validation_params, prune_params)[source]
abstract stopping_criterion(*args, **kwargs)[source]

Implements the stopping criterion for the particular validator

This function should return a target error value (e.g. the target error taking into account the magnitude of the objective and the absolute/relative tolerances).

In theory :fun:`error_estimation<KLMinimizationValidator.error_estimation>` could handle everything by itself. This abstract method aims to provide more structure to the code.

See the implementation :fun:`SampleAverageApproximationKLMinimizationValidator.stopping_criterion` for an example.

abstract error_estimation(base_distribution, pull_tar, error_estimation_params, *args, **kwargs)[source]
abstract refinement(base_distribution, pull_tar, qtype, qparams, ref_params, *args, **kwargs)[source]
Returns:

(tuple) – containing the new qparams and the

number of points corresponding to it.

class TransportMaps.Diagnostics.Validators.SampleAverageApproximationKLMinimizationValidator(eps, eps_abs=1e-13, cost_function=no_cost_function, max_cost=np.inf, max_nsamps=np.inf, stop_on_fcast=False, upper_mult=10, lower_n=2, alpha=0.05, lmb_def=2, lmb_max=10)[source]

Bases: KLMinimizationValidator

Base object for every object in the module.

This object provides functions for storage and parallelization.

print_info(err, target_err, cost, validation_params, prune_params)[source]
stopping_criterion(err_mag=None)[source]

Implements the stopping criterion for the particular validator

This function should return a target error value (e.g. the target error taking into account the magnitude of the objective and the absolute/relative tolerances).

In theory :fun:`error_estimation<KLMinimizationValidator.error_estimation>` could handle everything by itself. This abstract method aims to provide more structure to the code.

See the implementation :fun:`SampleAverageApproximationKLMinimizationValidator.stopping_criterion` for an example.

error_estimation(base_distribution, pull_tar, validation_params, full_output=False, mpi_pool=None)[source]
refinement(base_distribution, pull_tar, validation_params)[source]
Returns:

(tuple) – containing the new qparams and the

number of points corresponding to it.

class TransportMaps.Diagnostics.Validators.GradientBootstrapKLMinimizationValidator(eps, delta=5, cost_function=no_cost_function, max_cost=np.inf, max_nsamps=np.inf, stop_on_fcast=False, n_grad_samps=1, n_bootstrap=2000, alpha=0.95, lmb_min=2, lmb_max=10)[source]

Bases: KLMinimizationValidator

Bootstrap the gradient to check whether cost function is flat independently of the sample.

For the current solution \({\bf a}\), minimizing the cost \(\mathcal{Q}_n[\mathcal{J}[{\bf a}]({\bf x})]\), for the sample \({\bf x}^\star\), check that

\[\mathbb{P}\left[ \left\Vert\mathcal{Q}_n[\nabla_{\bf a}\mathcal{J}[{\bf a}]({\bf x})]\right\Vert_2 \leq \delta \left\Vert\mathcal{Q}_n[\nabla_{\bf a}\mathcal{J}[{\bf a}]({\bf x}^\star)]\right\Vert_2 + \varepsilon \right] \geq \alpha\]
Parameters:

delta (float) – multiplicative factor \(\delta\)

update_tolerances()[source]
pre_solve(base_distribution, target_distribution, transport_map, validation_params)[source]

Implements a routine to be initialize variables before the solving stage.

This function should initialize quantities that are needed for a particular validator.

stopping_criterion(obj=None, grad=None, validation_params=None)[source]

Implements the stopping criterion for the particular validator

This function should return a target error value (e.g. the target error taking into account the magnitude of the objective and the absolute/relative tolerances).

In theory :fun:`error_estimation<KLMinimizationValidator.error_estimation>` could handle everything by itself. This abstract method aims to provide more structure to the code.

See the implementation :fun:`SampleAverageApproximationKLMinimizationValidator.stopping_criterion` for an example.

error_estimation(base_distribution, pull_tar, validation_params, full_output=False, mpi_pool=None)[source]
refinement(base_distribution, pull_tar, validation_params)[source]
Returns:

(tuple) – containing the new qparams and the

number of points corresponding to it.

class TransportMaps.Diagnostics.Validators.DimensionAdaptiveSparseGridKLMinimizationValidator(*args, **kwargs)[source]

Bases: KLMinimizationValidator

Base object for every object in the module.

This object provides functions for storage and parallelization.

grad_l2_reg(alpha, pull_tar)[source]
grad_a_log_pdf_call(pull_tar, solve_params)[source]
pre_solve(base_distribution, target_distribution, transport_map, validation_params)[source]

Implements a routine to be initialize variables before the solving stage.

This function should initialize quantities that are needed for a particular validator.

post_solve(base_distribution, target_distribution, transport_map, validation_params)[source]

Implements a routine to be make sure the variables set in presolve are in the correct state post exiting the solving stage.

Since, in principle, algorithms can be stopped and re-started, this allows variables to be cleaned up when not needed.

print_info(err, target_err, cost, validation_params, prune_params)[source]
stopping_criterion(solve_params)[source]

Implements the stopping criterion for the particular validator

This function should return a target error value (e.g. the target error taking into account the magnitude of the objective and the absolute/relative tolerances).

In theory :fun:`error_estimation<KLMinimizationValidator.error_estimation>` could handle everything by itself. This abstract method aims to provide more structure to the code.

See the implementation :fun:`SampleAverageApproximationKLMinimizationValidator.stopping_criterion` for an example.

error_estimation(base_distribution, pull_tar, validation_params, full_output=False)[source]
refinement(base_distribution, pull_tar, validation_params)[source]
Returns:

(tuple) – containing the new qparams and the

number of points corresponding to it.