GPSat.models.multioutput package
Submodules
GPSat.models.multioutput.gpr module
- class GPSat.models.multioutput.gpr.MultioutputGPR(data, kernel, num_latent_gps, mean_function=None, noise_variance=None, likelihood: LinearModelLikelihood = None)
Bases:
GPR
- log_marginal_likelihood() Tensor
Computes the log marginal likelihood.
\[\log p(Y | \theta).\]- Returns:
return has shape [].
- predict_f(Xnew, full_cov: bool = False, full_output_cov: bool = False)
For backwards compatibility, GPR’s predict_f uses the fused (no-cache) computation, which is more efficient during training.
- For faster (cached) prediction, predict directly from the posterior object, i.e.,:
model.posterior().predict_f(Xnew, …)
- Parameters:
Xnew –
Xnew has shape [batch…, N, D].
- Returns:
return[0] has shape [batch…, N, P].
return[1] has shape [batch…, N, P, N, P] if full_cov and full_output_cov.
return[1] has shape [batch…, N, P, P] if (not full_cov) and full_output_cov.
return[1] has shape [batch…, N, P] if (not full_cov) and (not full_output_cov).
return[1] has shape [batch…, P, N, N] if full_cov and (not full_output_cov).
- class GPSat.models.multioutput.gpr.MultioutputSVGP(kernel: LinearCoregionalization, likelihood: ForwardModelLikelihood, inducing_variable: InducingVariables | Tensor | ndarray[Any, Any], *, mean_function: MeanFunction | None = None, q_diag: bool = False, q_mu: Tensor | None = None, q_sqrt: Tensor | None = None, num_data: Tensor | None = None)
Bases:
SVGP
- elbo(data) Tensor
This gives a variational bound (the evidence lower bound or ELBO) on the log marginal likelihood of the model.
- Returns:
return has shape [].
GPSat.models.multioutput.likelihoods module
- class GPSat.models.multioutput.likelihoods.ForwardModelLikelihood(variance: Tensor, *args, **kwargs)
Bases:
ABC
Base class for likelihoods defined via a measurement model y = h(x) + noise This requires a) a forward model h(x) and b) a measurement error covariance R
- abstract get_model(*args, **kwargs) ForwardModel
Returns a ForwardModel object defining h(x)
- class GPSat.models.multioutput.likelihoods.LinearModelLikelihood(input_dim: int, variance: Tensor, forward_model: Tensor | LinearForwardModel)
Bases:
Likelihood
,ForwardModelLikelihood
Implements likelihood of form y = Hx + noise for a linear operator H
- get_model(input_dim, forward_model)
Returns a ForwardModel object defining h(x)
- predict_log_density(X, Fmu, Fcov, Y)
Given a Normal distribution for the latent function, and a datum Y, compute the log predictive density of Y,
- i.e. if
q(F) = N(Fmu, Fvar)
and this object represents
p(y|F)
then this method computes the predictive density
log ∫ p(y=Y|F)q(F) df
- Parameters:
X –
X has shape [broadcast batch…, input_dim].
input tensor
Fmu –
Fmu has shape [broadcast batch…, latent_dim].
mean function evaluation tensor
Fvar –
Fvar has shape [broadcast batch…, latent_dim].
variance of function evaluation tensor
Y –
Y has shape [broadcast batch…, observation_dim].
observation tensor
- Returns:
return has shape [batch…].
log predictive density
- predict_mean_and_var(X, Fmu, Fcov)
Given a Normal distribution for the latent function, return the mean and marginal variance of Y,
- i.e. if
q(f) = N(Fmu, Fvar)
and this object represents
p(y|f)
then this method computes the predictive mean
∫∫ y p(y|f)q(f) df dy
and the predictive variance
∫∫ y² p(y|f)q(f) df dy - [ ∫∫ y p(y|f)q(f) df dy ]²
- Parameters:
X –
X has shape [broadcast batch…, input_dim].
input tensor
Fmu –
Fmu has shape [broadcast batch…, latent_dim].
mean function evaluation tensor
Fvar –
Fvar has shape [broadcast batch…, latent_dim].
variance of function evaluation tensor
- Returns:
return[0] has shape [batch…, observation_dim].
return[1] has shape [batch…, observation_dim].
mean and variance
- variance_at(X) Tensor
- variational_expectations(X, Fmu, Fcov, Y)
Compute the expected log density of the data, given a Gaussian distribution for the function values,
- i.e. if
q(f) = N(Fmu, Fvar)
and this object represents
p(y|f)
then this method computes
∫ log(p(y=Y|f)) q(f) df.
This only works if the broadcasting dimension of the statistics of q(f) (mean and variance) are broadcastable with that of the data Y.
- Parameters:
X –
X has shape [broadcast batch…, input_dim].
input tensor
Fmu –
Fmu has shape [broadcast batch…, latent_dim].
mean function evaluation tensor
Fvar –
Fvar has shape [broadcast batch…, latent_dim].
variance of function evaluation tensor
Y –
Y has shape [broadcast batch…, observation_dim].
observation tensor
- Returns:
return has shape [batch…].
expected log density of the data given q(F)
- class GPSat.models.multioutput.likelihoods.NonlinearModelLikelihood(forward_model: ForwardModel, variance: Tensor, num_samples: int = 100)
Bases:
MonteCarloLikelihood
,ForwardModelLikelihood
Implements likelihood of form y = h(x) + noise for a nonlinear operator h The variational expectation ∫log p(y|f)q(f)df is computed using Monte-Carlo method
- get_model(forward_model)
Returns a ForwardModel object defining h(x)
- variational_expectations(X, Fmu, Fcov, Y)
Compute the expected log density of the data, given a Gaussian distribution for the function values,
- i.e. if
q(f) = N(Fmu, Fvar)
and this object represents
p(y|f)
then this method computes
∫ log(p(y=Y|f)) q(f) df.
This only works if the broadcasting dimension of the statistics of q(f) (mean and variance) are broadcastable with that of the data Y.
- Parameters:
X –
X has shape [broadcast batch…, input_dim].
input tensor
Fmu –
Fmu has shape [broadcast batch…, latent_dim].
mean function evaluation tensor
Fvar –
Fvar has shape [broadcast batch…, latent_dim].
variance of function evaluation tensor
Y –
Y has shape [broadcast batch…, observation_dim].
observation tensor
- Returns:
return has shape [batch…].
expected log density of the data given q(F)
GPSat.models.multioutput.models module
GPSat.models.multioutput.utils module
- class GPSat.models.multioutput.utils.ForwardModel(input_dim: int, latent_dim: int, observation_dim: int, *args, **kwargs)
Bases:
ABC
- class GPSat.models.multioutput.utils.LinearForwardModel(input_dim: int, latent_dim: int, observation_dim: int, H: Tensor | ndarray)
Bases:
ForwardModel
Class for linear forward models y = Hx where H is a P x L matrix
- propagate_cov(Fcov: Tensor)
Computes the second moment ∫ (H(x-μ))’(H(x-μ)) p(x)dx = HΣH’ where Σ is the covariance of x
- propagate_mean(Fmu: Tensor)
Computes the first moment ∫ Hx p(x)dx = Hμ where μ is the mean of x
- GPSat.models.multioutput.utils.add_likelihood_noise_cov(K, R)
- GPSat.models.multioutput.utils.multioutput_conditional(Kmn: Tensor, Kmm: Tensor, Knn: Tensor, f: Tensor, H: Tensor, R: Tensor, *, full_cov=False)
- GPSat.models.multioutput.utils.multivariate_gaussian_log_density(x, mu, cov) Tensor