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
The output (Y) dimensionality, or 1 for a single kernel shared across all outputs.
The input (X) dimensionality, or 1 for an isotropic kernel.
data
folder
The implementation of this Kernel in GPFlow.
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) –
- 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
todst_folder
.- Parameters:
dst_folder (Path | str) – The folder to move to. If this exists, it will be emptied.
- Return type:
Returns:
self
for chaining calls.
- classmethod read(folder, **kwargs)§
Read
Data
fromfolder
.- Parameters:
- Return type:
Returns: The
Data
stored infolder
.
- 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.
- 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:
- 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. Ifself.variance.shape == (L,L)
a 1-tuple of multi-output kernels is returned.