# ab.kernels¶

Random kernel classes for use with the RandomKernel layers.

class aboleth.kernels.Matern(lenscale=1.0, p=1)

Matern kernel approximation.

Parameters: lenscale (float, ndarray, Tensor, Variable) – the length scales of the shift invariant kernel, this can be a scalar for an isotropic kernel, or a vector of shape (input_dim, 1) for an automatic relevance detection (ARD) kernel. If you wish to learn this parameter, make it a Variable (or ab.pos(tf.Variable(...)) to keep it positively constrained). p (int) – a zero or positive integer specifying the number of the Matern kernel, e.g. p == 0 results int a Matern 1/2 kernel, p == 1 results in the Matern 3/2 kernel etc.
weights(input_dim, n_features, dtype=<class 'numpy.float32'>)

Generate the random fourier weights for this kernel.

Parameters: input_dim (int) – the input dimension to this layer. n_features (int) – the number of unique random features, the actual output dimension of this layer will be 2 * n_features. dtype (np.dtype) – the dtype of the features to draw, this should match the observations. P (ndarray) – the random weights of the fourier features of shape (input_dim, n_features). KL (Tensor, float) – the KL penalty associated with the parameters in this kernel (0.0).
class aboleth.kernels.RBF(lenscale=1.0)

Parameters: lenscale (float, ndarray, Tensor, Variable) – the length scales of the shift invariant kernel, this can be a scalar for an isotropic kernel, or a vector of shape (input_dim, 1) for an automatic relevance detection (ARD) kernel. If you wish to learn this parameter, make it a Variable (or ab.pos(tf.Variable(...)) to keep it positively constrained).
weights(input_dim, n_features, dtype=<class 'numpy.float32'>)

Generate the random fourier weights for this kernel.

Parameters: input_dim (int) – the input dimension to this layer. n_features (int) – the number of unique random features, the actual output dimension of this layer will be 2 * n_features. dtype (np.dtype) – the dtype of the features to draw, this should match the observations. P (ndarray) – the random weights of the fourier features of shape (input_dim, n_features). KL (Tensor, float) – the KL penalty associated with the parameters in this kernel (0.0).
class aboleth.kernels.RBFVariational(lenscale=1.0, lenscale_posterior=None)

This kernel is similar to the RBF kernel, however we learn an independant Gaussian posterior distribution over the kernel weights to sample from.

Parameters: lenscale (float, ndarray, Tensor, Variable) – the length scales of the shift invariant kernel, this can be a scalar for an isotropic kernel, or a vector of shape (input_dim, 1) for an automatic relevance detection (ARD) kernel. If you wish to learn this parameter, make it a Variable (or ab.pos(tf.Variable(...)) to keep it positively constrained). lenscale_posterior (float, ndarray, optional) – the initial value for the posterior length scale, this can be a scalar or vector (different initial value per input dimension). If this is left as None, it will be set to sqrt(1 / input_dim) (this is similar to the ‘auto’ setting for a scikit learn SVM with a RBF kernel).
weights(input_dim, n_features, dtype=<class 'numpy.float32'>)

Generate the random fourier weights for this kernel.

Parameters: input_dim (int) – the input dimension to this layer. n_features (int) – the number of unique random features, the actual output dimension of this layer will be 2 * n_features. dtype (np.dtype) – the dtype of the features to draw, this should match the observations. P (ndarray) – the random weights of the fourier features of shape (input_dim, n_features). KL (Tensor, float) – the KL penalty associated with the parameters in this kernel.
class aboleth.kernels.ShiftInvariant(lenscale=1.0)

Bases: object

Abstract base class for shift invariant kernel approximations.

Parameters: lenscale (float, ndarray, Tensor, Variable) – the length scales of the shift invariant kernel, this can be a scalar for an isotropic kernel, or a vector of shape (input_dim, 1) for an automatic relevance detection (ARD) kernel. If you wish to learn this parameter, make it a Variable (or ab.pos(tf.Variable(...)) to keep it positively constrained).
weights(input_dim, n_features, dtype=<class 'numpy.float32'>)

Generate the random fourier weights for this kernel.

Parameters: input_dim (int) – the input dimension to this layer. n_features (int) – the number of unique random features, the actual output dimension of this layer will be 2 * n_features. dtype (np.dtype) – the dtype of the features to draw, this should match the observations. P (ndarray) – the random weights of the fourier features of shape (input_dim, n_features). KL (Tensor, float) – the KL penalty associated with the parameters in this kernel.