deformation
MuyGPyS.gp.deformation module reference.
- class MuyGPyS.gp.deformation.Isotropy(metric, length_scale)[source]
An isotropic deformation model.
Isotropy defines a scaled elementwise distance function \(d_ell(\cdot, \cdot)\), and is paramterized by a scalar \(\ell>0\) length scale hyperparameter.
\[d_\ell(\mathbf{x}, \mathbf{y}) = \sum_{i=0}^d \frac{d(\mathbf{x}_i, \mathbf{y}_i)}{\ell}\]- Parameters:
metric (
Callable
) – A callable metric function that takes a tensor of shape (…, feature_count) whose last dimension lists the elementwise differences between a pair of feature vectors and returns a tensor of shape (…), having collapsed the last dimension into a scalar difference.length_scale (
Parameter
) – Some scalar nonnegative hyperparameter object.
- __call__(diffs, length_scale=None, **kwargs)[source]
Apply isotropic deformation to an elementwise difference tensor.
This function is not intended to be invoked directly by a user. It is instead functionally incorporated into some
MuyGPyS.gp.kernels.KernelFn
in its constructor.- Parameters:
diffs (
ndarray
) – A tensor of pairwise differences of shape (…, feature_count).length_scale (
Optional
[float
]) – A floating point length scale.
- Return type:
ndarray
- Returns:
A crosswise distance matrix of shape (data_count, nn_count) or a pairwise distance tensor of shape (data_count, nn_count, nn_count) whose last two dimensions are pairwise distance matrices.
- embed_fn(fn)[source]
Augments a function to automatically apply the deformation to a difference tensor.
- Parameters:
fn (
Callable
) – A Callable with signature (diffs, *args, **kwargs) -> mm.ndarray taking a difference tensor diffs with shape (…, feature_count).- Return type:
Callable
- Returns:
A new Callable that applies the deformation to diffs, removing the last tensor dimension by collapsing the feature-wise differences into scalar distances. Also adds a length_scale kwarg, making the function drivable by keyword optimization.
- get_opt_params()[source]
Report lists of unfixed hyperparameter names, values, and bounds.
- Return type:
Tuple
[List
[str
],List
[float
],List
[Tuple
[float
,float
]]]- Returns:
- names:
A list of unfixed hyperparameter names.
- params:
A list of unfixed hyperparameter values.
- bounds:
A list of unfixed hyperparameter bound tuples.
- class MuyGPyS.gp.deformation.Anisotropy(metric, **length_scales)[source]
An anisotropic deformation model.
Anisotropy parameterizes a scaled elementwise distance function \(d_\ell(\cdot, \cdot)\), and is paramterized by a vector-valued \(\mathbf{\ell}>0\) length scale hyperparameter.
\[d_\ell(\mathbf{x}, \mathbf{y}) = \sum_{i=0}^d \frac{d(\mathbf{x}_i, \mathbf{y}_i)}{\ell_i}\]- Parameters:
metric (
Callable
) – A callable metric function that takes a tensor of shape (…, feature_count) whose last dimension lists the elementwise differences between a pair of feature vectors and returns a tensor of shape (…), having collapsed the last dimension into a scalar difference.length_scales – Keyword arguments length_scale#, mapping to scalar hyperparameters.
- __call__(diffs, **length_scales)[source]
Apply anisotropic deformation to an elementwise difference tensor.
This function is not intended to be invoked directly by a user. It is instead functionally incorporated into some
MuyGPyS.gp.kernels.KernelFn
in its constructor.- Parameters:
diffs (
ndarray
) – A tensor of pairwise differences of shape (…, feature_count).batch_features – A (batch_count, feature_count) matrix of features to be used with a hierarchical hyperparameter. None otherwise.
length_scale – A floating point length scale, or a vector of (knot_count,) knot length scales.
- Return type:
ndarray
- Returns:
A crosswise distance matrix of shape (data_count, nn_count) or a pairwise distance tensor of shape (data_count, nn_count, nn_count) whose last two dimensions are pairwise distance matrices.
- embed_fn(fn)[source]
Augments a function to automatically apply the deformation to a difference tensor.
- Parameters:
fn (
Callable
) – A Callable with signature (diffs, *args, **kwargs) -> mm.ndarray taking a difference tensor diffs with shape (…, feature_count).- Return type:
Callable
- Returns:
A new Callable that applies the deformation to diffs, removing the last tensor dimension by collapsing the feature-wise differences into scalar distances. Propagates any length_scaleN kwargs to the deformation fn, making the function drivable by keyword optimization.
- get_opt_params()[source]
Report lists of unfixed hyperparameter names, values, and bounds.
- Return type:
Tuple
[List
[str
],List
[float
],List
[Tuple
[float
,float
]]]- Returns:
- names:
A list of unfixed hyperparameter names.
- params:
A list of unfixed hyperparameter values.
- bounds:
A list of unfixed hyperparameter bound tuples.