Multitask GPs¶
Multitask GPs can fit to multiple output values.
Multitask¶
Enabling multitask Gaussian processes.
The Multitask decorator
converts a controller class into a multitask controller.
- class vanguard.multitask.decorator.Multitask(num_tasks, lmc_dimension=None, rank=1, **kwargs)[source]¶
Bases:
DecoratorMake a GP multitask.
- Example:
>>> from vanguard.base import GPController >>> >>> @Multitask(num_tasks=2) ... class MyController(GPController): ... pass
- Parameters:
- __init__(num_tasks, lmc_dimension=None, rank=1, **kwargs)[source]¶
Initialise self.
- Parameters:
num_tasks (
int) – The number of tasks (i.e. y-value dimension).lmc_dimension (
Optional[int]) – If using LMC (linear model of co-regionalisation), how many latent dimensions to use. Bigger means a more complicated model. Should probably be at least as big as the number of tasks, unless you want to specifically make low-rank assumptions about the relationship between tasks. Default (None) means LMC is not used at all.rank (
int) – The rank of the task-task covar matrix in a Kronecker product multitask kernel. Only relevant for exact GP inference.kwargs (
Any)
- property safe_updates: dict[type, set[str]]¶
Get a dictionary (class -> set[names]) of overrides/new methods that we consider “safe”.
- verify_decorated_class(cls)[source]¶
Verify that a class can be decorated by this instance.
- Parameters:
- Raises:
TypeError – If cls is not a subclass of the framework_class.
TopmostDecoratorError – If cls is already decorated with a
TopMostDecorator.MissingRequirementsError – If cls is missing a required decorator.
- Return type:
Multitask Likelihoods¶
Contains GPyTorch likelihoods required in Vanguard but not implemented in GPyTorch.
- class vanguard.multitask.likelihoods.FixedNoiseMultitaskGaussianLikelihood(noise, learn_additional_noise=False, batch_shape=(), **kwargs)[source]¶
A multitask likelihood with heteroskedastic noise.
Combines
gpytorch.likelihoods.MultitaskGaussianLikelihoodwithgpytorch.likelihoods.FixedNoiseGaussianLikelihoodto give a multitask Gaussian likelihood where a fixed heteroskedastic observation noise can be specified for each training point and task, but there is covariance between the points or the tasks.- __init__(noise, learn_additional_noise=False, batch_shape=(), **kwargs)[source]¶
Initialise self.
- Parameters:
noise (
Tensor) – (n_samples, n_tasks) The fixed observation noise.learn_additional_noise (
bool) – If to learn additional observation (likelihood) noise covariance along with the specified fixed noise. Takes the same form as the covariance ingpytorch.likelihoods.MultitaskGaussianLikelihood.batch_shape (
Size) – The batch shape of the learned noise parameter, defaults to emptySize.kwargs (
Any)
- marginal(function_dist, *params, noise=None, **kwargs)[source]¶
Return the marginal distribution.
If
rank == 0, adds the task noises to the diagonal of the covariance matrix of the suppliedgpytorch.distributions.MultivariateNormalorgpytorch.distributions.MultitaskMultivariateNormal. Otherwise, adds a rankrankcovariance matrix to it.To accomplish this, we form a new
linear_operator.operators.KroneckerProductLinearOperatorbetween \(I_{n}\), an identity matrix with size equal to the data and a (not necessarily diagonal) matrix containing the task noises \(D_{t}\).We also incorporate a shared
noiseparameter from the basegpytorch.likelihoods.GaussianLikelihoodthat we extend.There is also the fixed noise (supplied to
__init__()asnoise) represented as \(\sigma^*\) of length \(nt\) with task-contiguous blocks.The final covariance matrix after this method is then \(K + D_{t} \otimes I_{n} + \sigma^{2}I_{nt} + diag(\sigma^*)\).
- Parameters:
function_dist (
MultitaskMultivariateNormal) – Random variable whose covariance matrix is alinear_operator.LinearOperatorwe intend to augment.noise (
Optional[Tensor]) – The noise (standard deviation) to use in the likelihood, None, to use the likelihoods’s own fixed noise.params (
Any)kwargs (
Any)
- Return type:
- Returns:
A new random variable whose covariance matrix is a
linear_operator.LinearOperatorwith \(D_{t} \otimes I_{n}\), \(\sigma^{2}I_{nt}\) and \(diag(\sigma^*)\) added.