Parameters and priors
Parameter values
Only explicit Parameter leaves are fitted. Plain numbers and arrays remain
fixed. Parameters store unconstrained optimization coordinates and expose the
model value through .value.
| Constructor | Initial value | Constraint |
|---|---|---|
Parameter(unconstrained=...) |
Optimization coordinates | Identity transform by default |
PositiveParameter(value) |
Positive model value | Softplus |
CholeskyParameter(value) |
Lower-triangular model matrix | Positive diagonal and zero upper triangle |
PositiveParameter is used for trainable kernel variance, lengthscales, and
scalar observation-noise variance. CholeskyParameter is used for a full
input precision factor. A custom transform supplies forward and inverse.
Pass transform.inverse(value) to the base constructor's unconstrained
argument when starting from a constrained value.
See Fitting hyperparameters for a complete example.
Priors
A prior's log_prob receives the constrained model value and returns one scalar
joint log density. Scalar prior families sum independent contributions for
array-valued parameters. MultivariateLogNormalPrior describes the joint normal
distribution of the log-values. A correlated prior on ARD lengthscales still
uses an axis-aligned kernel metric.
MAP requires a prior on every trainable parameter. MLE ignores attached priors. The optimization transform adds no Jacobian term to the MAP objective, which is defined on the constrained model values.
For a full precision factor L, IndependentCholeskyPrior uses separate
priors for positive diagonal and unconstrained strict-lower entries.
ScaledLKJCholeskyPrior describes L = diag(scales) @ C, with positive scales
and a correlation Cholesky factor C. These correlations describe the input
precision metric. The prior includes the density correction from scales and
correlation coordinates to the free entries of L.
Custom priors provide a scalar log_prob(value). Built-in transforms and priors
implement the Transform and Prior interfaces below.
Classes and functions
gpex.parameters
Trainable parameters, optimization transforms, and priors.
Transform
Bases: Protocol
Map between optimization coordinates and constrained parameter values.
forward
abstractmethod
Parameter
Parameter(
*,
unconstrained: ParameterValue | float,
transform: Transform | None = None,
prior: Prior | None = None,
name: str | None = None,
)
Bases: Module
Trainable optimization coordinates with a transform and optional prior.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unconstrained
|
ParameterValue | float
|
Initial raw scalar or array, stored directly. The model
value is |
required |
transform
|
Transform | None
|
Map from optimization coordinates to constrained values.
Defaults to |
None
|
prior
|
Prior | None
|
Distribution with |
None
|
name
|
str | None
|
Optional diagnostic name. Defaults to |
None
|
Construction supports JIT. Use PositiveParameter(value) or
CholeskyParameter(value) to initialize from a constrained model value.
Source code in src/gpex/parameters/parameters.py
transform
class-attribute
instance-attribute
transform: Transform = (
IdentityTransform() if transform is None else transform
)
log_prior
Return the joint log density on value, or zero without a prior.
PositiveParameter
PositiveParameter(
value: ParameterValue | float,
*,
prior: Prior | None = None,
name: str | None = None,
)
Bases: Parameter
A positive scalar or array optimized through a softplus transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ParameterValue | float
|
Positive initial scalar or array, for example a lengthscale vector
of shape |
required |
prior
|
Prior | None
|
Optional joint prior on the complete positive value. Defaults to
|
None
|
name
|
str | None
|
Optional diagnostic name. Defaults to |
None
|
Construction supports JIT, batching, and differentiation of valid values. The transform, prior, and name remain static metadata.
Source code in src/gpex/parameters/parameters.py
CholeskyParameter
CholeskyParameter(
value: ParameterValue,
*,
prior: Prior | None = None,
name: str | None = None,
)
Bases: Parameter
A trainable lower-triangular matrix with positive diagonal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ParameterValue
|
Complete initial matrix of shape |
required |
prior
|
Prior | None
|
Optional joint prior on the complete constrained matrix. MAP
requires a prior; maximum likelihood does not. Defaults to |
None
|
name
|
str | None
|
Optional diagnostic name. Defaults to |
None
|
Only the d * (d + 1) / 2 free entries are optimized, in row-major order.
Diagonal entries use softplus; strict-lower entries are unrestricted. Priors
are evaluated on value without an optimization-coordinate Jacobian.
Construction supports JIT, batching, and differentiation of valid values;
the matrix shape, prior, and name remain static.
Source code in src/gpex/parameters/parameters.py
IdentityTransform
dataclass
Bases: Transform
forward
ExpTransform
dataclass
Bases: Transform
forward
SoftplusTransform
dataclass
Bases: Transform
forward
CholeskyTransform
dataclass
Bases: Transform
Pack a lower-triangular factor using unconstrained diagonal coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimension
|
int
|
Positive matrix dimension |
required |
forward maps a vector of shape (d * (d + 1) // 2,) to a matrix of
shape (d, d). Entries follow row-major lower-triangle order. Diagonal
coordinates use softplus, and strict-lower entries remain unrestricted.
inverse expects a finite lower-triangular matrix with positive diagonal.
Both operations support JIT, vmap, and differentiation of valid inputs.
forward
Source code in src/gpex/parameters/transforms.py
inverse
Source code in src/gpex/parameters/transforms.py
log_prior
Sum priors explicitly attached to all parameters in a PyTree.
Source code in src/gpex/parameters/parameters.py
gpex.parameters.priors
Distributions on constrained parameter values.
Prior
NormalPrior
dataclass
Bases: Prior
log_prob
Source code in src/gpex/parameters/priors.py
LogNormalPrior
dataclass
Bases: Prior
Independent log-normal densities with shared scalar hyperparameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_mean
|
float
|
Mean of each log-value. Defaults to 0. |
0.0
|
log_standard_deviation
|
float
|
Positive standard deviation of each log-value. Defaults to 1. Vector inputs use the same distribution per entry. |
1.0
|
log_prob
Source code in src/gpex/parameters/priors.py
MultivariateLogNormalPrior
dataclass
Bases: Prior
A joint log-normal prior on a positive vector of shape (d,).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_mean
|
ArrayLike
|
Finite mean vector of |
required |
log_covariance
|
ArrayLike
|
Finite, symmetric positive-definite covariance of
|
required |
Construct the prior outside JIT. Inputs may be arrays or Python sequences;
they are stored as immutable tuples because priors are static metadata on
a Parameter. The log density includes the log-normal Jacobian and is
evaluated on positive values, independently of their optimization transform.
Source code in src/gpex/parameters/priors.py
log_prob
Return the scalar joint log density, or -inf outside support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ParameterValue
|
Positive finite vector with shape |
required |
Returns:
| Type | Description |
|---|---|
Scalar
|
Scalar log density with respect to the positive vector. Entries that are
nonpositive or nonfinite give a density of |
Source code in src/gpex/parameters/priors.py
GammaPrior
dataclass
Bases: Prior
log_prob
Source code in src/gpex/parameters/priors.py
IndependentCholeskyPrior
dataclass
IndependentCholeskyPrior(
diagonal_prior: LogNormalPrior = LogNormalPrior(),
off_diagonal_prior: NormalPrior = NormalPrior(),
)
Bases: Prior
Independent log-normal diagonal and normal strict-lower entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diagonal_prior
|
LogNormalPrior
|
Log-normal distribution shared by the positive diagonal
entries. Defaults to |
LogNormalPrior()
|
off_diagonal_prior
|
NormalPrior
|
Normal distribution shared by the unrestricted
strict-lower entries. Defaults to |
NormalPrior()
|
The normalized joint density is with respect to the free entries of L.
off_diagonal_prior
class-attribute
instance-attribute
off_diagonal_prior: NormalPrior = NormalPrior()
log_prob
Return the joint log density, or -inf outside Cholesky support.
Source code in src/gpex/parameters/priors.py
ScaledLKJCholeskyPrior
dataclass
ScaledLKJCholeskyPrior(
concentration: float = 1.0,
scale_prior: Prior = LogNormalPrior(),
)
Bases: Prior
Positive row scales and an LKJ correlation factor as a prior on full L.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concentration
|
float
|
Positive LKJ concentration. Defaults to 1 (uniform over correlation matrices). Larger values favor weaker correlations. |
1.0
|
scale_prior
|
Prior
|
Joint prior on the positive row-norm vector of shape |
LogNormalPrior()
|
Decompose L = diag(scales) @ C, where each row of C has unit norm.
The normalized density includes the Jacobian from (scales, C) to the
free entries of L. For generalized kernels this describes the precision
matrix L @ L.T, not a covariance or lengthscale matrix.
log_prob
Return the joint log density, or -inf outside Cholesky support.