romcomma.gpr.kernels.Kernel§

class Kernel(folder, read_data=False, **kwargs)[source]§

Bases: Model

Abstract interface to a Kernel. Essentially this is the code contract with the MOGP interface.

Parameters:
  • folder (Path | str) –

  • read_data (bool) –

  • kwargs (NP.Matrix) –

__init__(folder, read_data=False, **kwargs)[source]§

Construct a Kernel. This must be called as a matter of priority by all implementations.

Parameters:
  • folder (Path | str) – The model file location.

  • read_data (bool) – If True, the data are read from folder, otherwise defaults are used.

  • **kwargs (ndarray) – The model.data fields=values to replace after reading from file/defaults.

Methods

TypeFromIdentifier(TypeIdentifier)

Convert a TypeIdentifier to a Kernel NamedTuple.

TypeFromParameters(parameters)

Recognize the NamedTuple of a Kernel from its Data.

__init__(folder[, read_data])

Construct a Kernel.

broadcast_parameters(variance_shape, M)

Broadcast this kernel to higher dimensions.

calibrate(**kwargs)

Merely sets which data are trainable.

read_meta()

write_meta(meta)

Attributes

L

The output (Y) dimensionality, or 1 for a single kernel shared across all outputs.

M

The input (X) dimensionality, or 1 for an isotropic kernel.

META

TYPE_IDENTIFIER

data

folder

implementation

The implementation of this Kernel in GPFlow.

is_covariant

Whether the kernel is covariant between outputs.

class Data(folder, **kwargs)[source]§

Bases: Data

The Data set of a Kernel.

Parameters:
  • folder (Path | str) –

  • kwargs (Data.Matrix) –

NamedTuple[source]§

alias of Values

static copy(src_folder, dst_folder)§

Returns a copy of src_folder at dst_folder, deleting anything existing at the destination.

Parameters:
  • src_folder (Path | str) –

  • dst_folder (Path | str) –

Return type:

Path

static delete(folder)§

Returns a non-existent folder.

Parameters:

folder (Path | str) –

Return type:

Path

static empty(folder)§

Returns an empty folder.

Parameters:

folder (Path | str) –

Return type:

Path

move(dst_folder)§

Move self to dst_folder.

Parameters:

dst_folder (Path | str) – The folder to move to. If this exists, it will be emptied.

Return type:

Data

Returns: self for chaining calls.

classmethod read(folder, **kwargs)§

Read Data from folder.

Parameters:
  • folder (Path | str) – The folder to record the data. Must exist

  • **kwargs (Frame | DataFrame | ndarray | Tensor) – key=ordinate initial pairs of NamedTuple fields, precisely as in NamedTuple(**kwargs). Missing fields receive their defaults, so Data(folder) is the default Data.

Return type:

Data

Returns: The Data stored in folder.

class property META: Dict[str, Any]§

Default meta data.

Type:

Returns

calibrate(**kwargs)[source]§

Merely sets which data are trainable.

Parameters:

kwargs (Any) –

Return type:

Dict[str, Any]

class property TYPE_IDENTIFIER: str§

The type of this Kernel object or class as ‘__module__.Kernel.__name__’.

classmethod TypeFromIdentifier(TypeIdentifier)[source]§

Convert a TypeIdentifier to a Kernel NamedTuple.

Parameters:

TypeIdentifier (str) – A string generated by Kernel.TypeIdentifier().

Returns:

The type of Kernel that _TypeIdentifier specifies.

Return type:

Type[Kernel]

classmethod TypeFromParameters(parameters)[source]§

Recognize the NamedTuple of a Kernel from its Data.

Parameters:

parameters (Data) – A Kernel.Data array to recognize.

Returns:

The type of Kernel that data defines.

Return type:

Type[Kernel]

property L: int§

The output (Y) dimensionality, or 1 for a single kernel shared across all outputs.

property M: int§

The input (X) dimensionality, or 1 for an isotropic kernel.

property is_covariant: bool§

Whether the kernel is covariant between outputs.

broadcast_parameters(variance_shape, M)[source]§

Broadcast this kernel to higher dimensions. Shrinkage raises errors, unchanged dimensions silently nop. A diagonal variance matrix broadcast to a square matrix is initially diagonal. All other expansions are straightforward broadcasts. :param variance_shape: The new shape for the variance, must be (1, L) or (L, L). :param M: The number of input Lengthscales per output.

Returns: self, for chaining calls. :raises IndexError: If an attempt is made to shrink a parameter.

Parameters:

variance_shape (Tuple[int, int]) –

Return type:

Kernel

abstract property implementation: Tuple[Any, ...]§

The implementation of this Kernel in GPFlow. If self.variance.shape == (1,L) an L-tuple of kernels is returned. If self.variance.shape == (L,L) a 1-tuple of multi-output kernels is returned.