Compositional input warping for GPs¶
Warped Gaussian Distribution¶
- class vanguard.warps.distribution.WarpedGaussian(warp, *args, **kwargs)[source]¶
Bases:
NormalA warped Gaussian distribution.
\[X\sim \mathcal{WN}(\psi; \mu, \sigma) ~ \iff \psi(X)\sim\mathcal{N}(\mu, \sigma).\]- Parameters:
warp (
WarpFunction)args (
Any)kwargs (
Any)
- __init__(warp, *args, **kwargs)[source]¶
- Parameters:
warp` – The warp to be used to define the distribution.
warp (
WarpFunction)args (
Any)kwargs (
Any)
- enumerate_support(expand=True)[source]¶
Returns tensor containing all values supported by a discrete distribution. The result will enumerate over dimension 0, so the shape of the result will be (cardinality,) + batch_shape + event_shape (where event_shape = () for univariate distributions).
Note that this enumerates over all batched tensors in lock-step [[0, 0], [1, 1], …]. With expand=False, enumeration happens along dim 0, but with the remaining batch dimensions being singleton dimensions, [[0], [1], ...
To iterate over the full Cartesian product use itertools.product(m.enumerate_support()).
- Args:
- expand (bool): whether to expand the support over the
batch dims to match the distribution’s batch_shape.
- Returns:
Tensor iterating over dimension 0.
- classmethod from_data(warp, samples, optimiser=<class 'torch.optim.adam.Adam'>, n_iterations=100, lr=0.001)[source]¶
Fit a warped Gaussian distribution to the given data using the supplied warp.
The mean and variance will be optimised along with the free parameters of the warp.
- Parameters:
warp (
WarpFunction) – The warp to use.samples (
Union[Tensor,ndarray[tuple[Any,...],dtype[floating]]]) – (n_samples, …) The data to fit.optimiser (
type[Optimizer]) – A subclass oftorch.optim.Optimizerused to tune the parameters.n_iterations (
int) – The number of optimisation iterations.lr (
float) – The learning rate for optimisation.
- Return type:
- Returns:
A fit distribution.
Input Warping¶
Contains the Python decorators for applying input warping.
- class vanguard.warps.input.SetInputWarp(warp_function, **kwargs)[source]¶
Apply input warping to a GP to achieve non-Gaussian input uncertainty.
- Example:
>>> from vanguard.base import GPController >>> from vanguard.warps.warpfunctions import BoxCoxWarpFunction >>> >>> @SetInputWarp(BoxCoxWarpFunction(1)) ... class MyController(GPController): ... pass
- Parameters:
warp_function (
WarpFunction)kwargs (
Any)
- __init__(warp_function, **kwargs)[source]¶
Initialise self.
- Parameters:
warp_function (
WarpFunction) – The warp function to be applied to the GP inputs.