DIRT
DIRT(
negloglik: Callable[[Tensor], Tensor],
neglogpri: Callable[[Tensor], Tensor],
preconditioner: Preconditioner,| List[Basis1D],
bases: Basis1D | None = None,
bridge: Bridge | None = None,
tt_options: TTOptions | None = None,
dirt_options: DIRTOptions int, SIRT] | None = None,
prev_approx: Dict[ )
Deep (squared) inverse Rosenblatt transport.
Parameters
negloglik : Callable[[Tensor], Tensor]
-
A function that receives an \(n \times d\) matrix of samples and returns an \(n\)-dimensional vector containing the negative log-likelihood function evaluated at each sample.
neglogpri : Callable[[Tensor], Tensor]
-
A function that receives an \(n \times d\) matrix of samples and returns an \(n\)-dimensional vector containing the negative log-prior density evaluated at each sample.
bases : Basis1D | List[Basis1D]
-
A list of sets of basis functions for each dimension, or a single set of basis functions (to be used in all dimensions), used to construct the functional tensor trains at each iteration.
bridge : Bridge | None = None
-
An object used to generate the intermediate densities to approximate at each stage of the DIRT construction.
tt_options : TTOptions | None = None
-
Options for constructing the FTT approximation to the square root of the ratio function (i.e., the pullback of the current bridging density under the existing composition of mappings) at each iteration.
dirt_options : DIRTOptions | None = None
-
Options for constructing the DIRT approximation to the target density.
prev_approx : Dict[int, SIRT] | None = None
-
A dictionary containing a set of SIRTs generated as part of the construction of a previous DIRT object.
References
Cui, T and Dolgov, S (2022). Deep composition of tensor-trains using squared inverse Rosenblatt transports. Foundations of Computational Mathematics 22, 1863–1922.
Methods
Name | Description |
---|---|
eval_potential | Evaluates the potential function. |
eval_potential_cond | Evaluates the conditional potential function. |
eval_rt | Evaluates the deep Rosenblatt transport. |
eval_irt | Evaluates the deep inverse Rosenblatt transport. |
eval_cirt | Evaluates the conditional inverse Rosenblatt transport. |
eval_irt_pullback | Evaluates the pullback of a density function. |
eval_cirt_pullback | Evaluates the pullback of a conditional density function. |
random | Generates a set of random samples. |
sobol | Generates a set of QMC samples. |
eval_potential
DIRT.eval_potential(
xs: Tensor,str | None = None,
subset: int | None = None,
n_layers: )
Evaluates the potential function.
Returns the joint potential function, or the marginal potential function for the first \(k\) variables or the last \(k\) variables, corresponding to the pullback of the reference measure under a given number of layers of the DIRT.
Parameters
xs : Tensor
-
An \(n \times k\) matrix containing a set of samples from the approximation domain.
subset : str | None = None
-
If the samples contain a subset of the variables, (i.e., \(k < d\)), whether they correspond to the first \(k\) variables (
subset='first'
) or the last \(k\) variables (subset='last'
). n_layers : int | None = None
-
The number of layers of the current DIRT construction to use when computing the potential. If not specified, all layers will be used when computing the potential.
Returns
neglogfxs : Tensor
-
An \(n\)-dimensional vector containing the potential function of the target density evaluated at each element in
xs
.
eval_potential_cond
DIRT.eval_potential_cond(
ys: Tensor,
xs: Tensor,str = 'first',
subset: int | None = None,
n_layers: )
Evaluates the conditional potential function.
Returns the conditional potential function evaluated at a set of samples in the approximation domain.
Parameters
ys : Tensor
-
An \(n \times k\) matrix containing samples from the approximation domain.
xs : Tensor
-
An \(n \times (d-k)\) matrix containing samples from the approximation domain.
subset : str = 'first'
-
Whether
ys
corresponds to the first \(k\) variables (subset='first'
) of the approximation, or the last \(k\) variables (subset='last'
). n_layers : int | None = None
-
The number of layers of the deep inverse Rosenblatt transport to push the samples forward under. If not specified, the samples will be pushed forward through all the layers.
Returns
neglogfxs : Tensor
-
An \(n\)-dimensional vector containing the potential function of the approximation to the conditional density of \(X \textbar Y\) evaluated at each sample in
xs
.
eval_rt
str | None = None, n_layers: int | None = None) DIRT.eval_rt(xs: Tensor, subset:
Evaluates the deep Rosenblatt transport.
Parameters
xs : Tensor
-
An \(n \times k\) matrix of samples from the approximation domain.
subset : str | None = None
-
If the samples contain a subset of the variables, (i.e., \(k < d\)), whether they correspond to the first \(k\) variables (
subset='first'
) or the last \(k\) variables (subset='last'
). n_layers : int | None = None
-
The number of layers of the deep inverse Rosenblatt transport to push the samples forward under. If not specified, the samples will be pushed forward through all the layers.
Returns
rs : Tensor
-
An \(n \times k\) matrix containing the composition of mappings evaluated at each value of
xs
. neglogfxs : Tensor
-
An \(n\)-dimensional vector containing the potential function of the pullback of the reference density under the current composition of mappings evaluated at each sample in
xs
.
eval_irt
DIRT.eval_irt(
rs: Tensor,str | None = None,
subset: int | None = None,
n_layers: )
Evaluates the deep inverse Rosenblatt transport.
Parameters
rs : Tensor
-
An \(n \times k\) matrix containing samples from the reference domain.
subset : str | None = None
-
If the samples contain a subset of the variables, (i.e., \(k < d\)), whether they correspond to the first \(k\) variables (
subset='first'
) or the last \(k\) variables (subset='last'
). n_layers : int | None = None
-
The number of layers of the deep inverse Rosenblatt transport to pull the samples back under. If not specified, the samples will be pulled back through all the layers.
Returns
xs : Tensor
-
An \(n \times k\) matrix containing the corresponding samples from the approximation domain, after applying the deep inverse Rosenblatt transport.
neglogfxs : Tensor
-
An \(n\)-dimensional vector containing the potential function of the pullback of the reference density under the current composition of mappings, evaluated at each sample in
xs
.
eval_cirt
DIRT.eval_cirt(
ys: Tensor,
rs: Tensor,str = 'first',
subset: int | None = None,
n_layers: )
Evaluates the conditional inverse Rosenblatt transport.
Returns the conditional inverse Rosenblatt transport evaluated at a set of samples in the approximation domain.
Parameters
ys : Tensor
-
A matrix containing samples from the approximation domain. The matrix should have dimensions \(1 \times k\) (if the same realisation of \(Y\) is to be used for all samples in
rs
) or \(n \times k\) (if a different realisation of \(Y\) is to be used for each samples inrs
). rs : Tensor
-
An \(n \times (d-k)\) matrix containing samples from the reference domain.
subset : str = 'first'
-
Whether
ys
corresponds to the first \(k\) variables (subset='first'
) of the approximation, or the last \(k\) variables (subset='last'
). n_layers : int | None = None
-
The number of layers of the DIRT object to use when evaluating the CIRT. If not specified, all layers will be used.
Returns
xs : Tensor
-
An \(n \times (d-k)\) matrix containing the realisations of \(X\) corresponding to the values of
rs
after applying the conditional inverse Rosenblatt transport. neglogfxs : Tensor
-
An \(n\)-dimensional vector containing the potential function of the approximation to the conditional density of \(X \textbar Y\) evaluated at each sample in
xs
.
eval_irt_pullback
DIRT.eval_irt_pullback(
potential: Callable[[Tensor], Tensor],
rs: Tensor,str | None = None,
subset: int | None = None,
n_layers: )
Evaluates the pullback of a density function.
This function evaluates \(\mathcal{T}^{\sharp}f(r)\), where \(\mathcal{T}(\cdot)\) denotes the inverse Rosenblatt transport and \(f(\cdot)\) denotes an arbitrary density function.
Parameters
potential : Callable[[Tensor], Tensor]
-
A function that takes an \(n \times k\) matrix of samples from the approximation domain, and returns an \(n\)-dimensional vector containing the potential function associated with \(f(\cdot)\) evaluated at each sample.
rs : Tensor
-
An \(n \times k\) matrix containing a set of samples from the reference domain.
subset : str | None = None
-
If the samples contain a subset of the variables, (i.e., \(k < d\)), whether they correspond to the first \(k\) variables (
subset='first'
) or the last \(k\) variables (subset='last'
). n_layers : int | None = None
-
The number of layers of the deep inverse Rosenblatt transport to pull the samples back under. If not specified, the samples will be pulled back through all the layers.
Returns
neglogTfrs : Tensor
-
An \(n\)-dimensional vector containing the potential of the pullback function evaluated at each element in
rs
; that is, \(-\log(\mathcal{T}^{\sharp}f(r))\). neglogfxs : Tensor
-
An \(n\)-dimensional vector containing the potential of the target function evaluated at each element in
rs
, pushed forward under the IRT; that is, \(-\log(f(\mathcal{T}(r)))\).
eval_cirt_pullback
DIRT.eval_cirt_pullback(
potential: Callable[[Tensor], Tensor],
ys: Tensor,
rs: Tensor,str = 'first',
subset: int | None = None,
n_layers: )
Evaluates the pullback of a conditional density function.
This function evaluates \(\mathcal{T}^{\sharp}f(r\|y)\), where \(\mathcal{T}(\cdot)\) denotes the inverse Rosenblatt transport and \(f(\cdot\|y)\) denotes an arbitrary conditional density function.
Parameters
potential : Callable[[Tensor], Tensor]
-
A function that takes an \(n \times (d-k)\) matrix of samples from the approximation domain, and returns an \(n\)-dimensional vector containing the potential function associated with \(f(\cdot\\|y)\) evaluated at each sample.
ys : Tensor
-
A matrix containing samples from the approximation domain. The matrix should have dimensions \(1 \times k\) (if the same realisation of \(Y\) is to be used for all samples in
rs
) or \(n \times k\) (if a different realisation of \(Y\) is to be used for each samples inrs
). rs : Tensor
-
An \(n \times (d-k)\) matrix containing a set of samples from the reference domain.
subset : str = 'first'
-
Whether
ys
corresponds to the first \(k\) variables (subset='first'
) of the approximation, or the last \(k\) variables (subset='last'
). n_layers : int | None = None
-
The number of layers of the deep inverse Rosenblatt transport to pull the samples back under. If not specified, the samples will be pulled back through all the layers.
Returns
neglogTfrs : Tensor
-
An \(n\)-dimensional vector containing the potential of the pullback function evaluated at each element in
rs
; that is, \(-\log(\mathcal{T}^{\sharp}f(r\\|y))\). neglogfxs : Tensor
-
An \(n\)-dimensional vector containing the potential of the target function evaluated at each element in
rs
, pushed forward under the IRT; that is, \(-\log(f(\mathcal{T}(r)\\|y))\).
random
int) DIRT.random(n:
Generates a set of random samples.
The samples are distributed according to the DIRT approximation to the target density.
Parameters
n : int
-
The number of samples to generate.
Returns
xs : Tensor
-
An \(n \times d\) matrix containing the generated samples.
sobol
int) DIRT.sobol(n:
Generates a set of QMC samples.
The samples are distributed according to the DIRT approximation to the target density.
Parameters
n : int
-
The number of samples to generate.
Returns
xs : Tensor
-
An \(n \times d\) matrix containing the generated samples.