Skip to content

Periodic

gpjax.kernels.stationary.periodic

Periodic dataclass

Bases: AbstractKernel

The periodic kernel.

Key reference is MacKay 1998 - "Introduction to Gaussian processes".

compute_engine: AbstractKernelComputation = static_field(DenseKernelComputation()) class-attribute instance-attribute
active_dims: Optional[List[int]] = static_field(None) class-attribute instance-attribute
ndims property
spectral_density: Optional[tfd.Distribution] property
lengthscale: Union[ScalarFloat, Float[Array, ' D']] = param_field(jnp.array(1.0), bijector=tfb.Softplus()) class-attribute instance-attribute
variance: ScalarFloat = param_field(jnp.array(1.0), bijector=tfb.Softplus()) class-attribute instance-attribute
period: ScalarFloat = param_field(jnp.array(1.0), bijector=tfb.Softplus()) class-attribute instance-attribute
name: str = 'Periodic' class-attribute instance-attribute
__init_subclass__(mutable: bool = False)
replace(**kwargs: Any) -> Self

Replace the values of the fields of the object.

Parameters:

Name Type Description Default
**kwargs Any

keyword arguments to replace the fields of the object.

{}
Returns
Module: with the fields replaced.
replace_meta(**kwargs: Any) -> Self

Replace the metadata of the fields.

Parameters:

Name Type Description Default
**kwargs Any

keyword arguments to replace the metadata of the fields of the object.

{}
Returns
Module: with the metadata of the fields replaced.
update_meta(**kwargs: Any) -> Self

Update the metadata of the fields. The metadata must already exist.

Parameters:

Name Type Description Default
**kwargs Any

keyword arguments to replace the fields of the object.

{}
Returns
Module: with the fields replaced.
replace_trainable(**kwargs: Dict[str, bool]) -> Self

Replace the trainability status of local nodes of the Module.

replace_bijector(**kwargs: Dict[str, tfb.Bijector]) -> Self

Replace the bijectors of local nodes of the Module.

constrain() -> Self

Transform model parameters to the constrained space according to their defined bijectors.

Returns
Module: transformed to the constrained space.
unconstrain() -> Self

Transform model parameters to the unconstrained space according to their defined bijectors.

Returns
Module: transformed to the unconstrained space.
stop_gradient() -> Self

Stop gradients flowing through the Module.

Returns
Module: with gradients stopped.
trainables() -> Self
cross_covariance(x: Num[Array, 'N D'], y: Num[Array, 'M D'])
gram(x: Num[Array, 'N D'])
slice_input(x: Float[Array, '... D']) -> Float[Array, '... Q']

Slice out the relevant columns of the input matrix.

Select the relevant columns of the supplied matrix to be used within the kernel's evaluation.

Parameters:

Name Type Description Default
x Float[Array, '... D']

The matrix or vector that is to be sliced.

required
Returns
Float[Array, "... Q"]: A sliced form of the input matrix.
__add__(other: Union[AbstractKernel, ScalarFloat]) -> AbstractKernel

Add two kernels together. Args: other (AbstractKernel): The kernel to be added to the current kernel.

Returns
AbstractKernel: A new kernel that is the sum of the two kernels.
__radd__(other: Union[AbstractKernel, ScalarFloat]) -> AbstractKernel

Add two kernels together. Args: other (AbstractKernel): The kernel to be added to the current kernel.

Returns
AbstractKernel: A new kernel that is the sum of the two kernels.
__mul__(other: Union[AbstractKernel, ScalarFloat]) -> AbstractKernel

Multiply two kernels together.

Parameters:

Name Type Description Default
other AbstractKernel

The kernel to be multiplied with the current kernel.

required
Returns
AbstractKernel: A new kernel that is the product of the two kernels.
__init__(compute_engine: AbstractKernelComputation = static_field(DenseKernelComputation()), active_dims: Optional[List[int]] = static_field(None), name: str = 'Periodic', lengthscale: Union[ScalarFloat, Float[Array, ' D']] = param_field(jnp.array(1.0), bijector=tfb.Softplus()), variance: ScalarFloat = param_field(jnp.array(1.0), bijector=tfb.Softplus()), period: ScalarFloat = param_field(jnp.array(1.0), bijector=tfb.Softplus())) -> None
__call__(x: Float[Array, ' D'], y: Float[Array, ' D']) -> ScalarFloat

Compute the Periodic kernel between a pair of arrays.

Evaluate the kernel on a pair of inputs (x,y)(x, y) with length-scale parameter β„“\ell, variance Οƒ2\sigma^2 and period pp.

k(x,y)=Οƒ2exp⁑(βˆ’12βˆ‘i=1D(sin⁑(Ο€(xiβˆ’yi)/p)β„“)2) k(x, y) = \sigma^2 \exp \left( -\frac{1}{2} \sum_{i=1}^{D} \left(\frac{\sin (\pi (x_i - y_i)/p)}{\ell}\right)^2 \right)

Parameters:

Name Type Description Default
x Float[Array, ' D']

The left hand argument of the kernel function's call.

required
y Float[Array, ' D']

The right hand argument of the kernel function's call

required

Returns: ScalarFloat: The value of k(x,y)k(x, y).