h0rton.h0_inference.gaussian_bnn_posterior_cpu¶
Module Contents¶
Classes¶
BaseGaussianBNNPosteriorCPU |
Abstract base class to represent the Gaussian BNN posterior |
DiagonalGaussianBNNPosteriorCPU |
The negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix |
LowRankGaussianBNNPosteriorCPU |
The negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix |
DoubleLowRankGaussianBNNPosteriorCPU |
The negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix |
FullRankGaussianBNNPosteriorCPU |
The negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix |
DoubleGaussianBNNPosteriorCPU |
The negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix |
Functions¶
sigmoid(x) |
|
logsigmoid(x) |
-
class
h0rton.h0_inference.gaussian_bnn_posterior_cpu.BaseGaussianBNNPosteriorCPU(Y_dim, Y_mean=None, Y_std=None)[source]¶ Bases:
abc.ABCAbstract base class to represent the Gaussian BNN posterior
Gaussian posteriors or mixtures thereof with various forms of the covariance matrix inherit from this class.
-
sample(self, n_samples, sample_seed=None)[source]¶ Sample from the Gaussian posterior. Must be overridden by subclasses.
- n_samples : int
- how many samples to obtain
- sample_seed : int
- seed for the samples. Default: None
- np.array of shape [n_samples, self.Y_dim]
- samples
-
transform_back_mu(self, array)[source]¶ Transform back, i.e. unwhiten, the tensor of central values
array : np.array of shape [batch_size, Y_dim]
- torch.tensor of shape [batch_size, Y_dim]
- the original tensor
-
unwhiten_back(self, sample)[source]¶ Scale and shift back to the unwhitened state
- pred : torch.Tensor
- network prediction of shape [batch_size, n_samples, self.Y_dim]
- torch.Tensor
- the unwhitened pred
-
sample_low_rank(self, n_samples, mu, logvar, F)[source]¶ Sample from a single Gaussian posterior with a full but low-rank plus diagonal covariance matrix
- n_samples : int
- how many samples to obtain
- mu : torch.Tensor of shape [self.batch_size, self.Y_dim]
- network prediction of the mu (mean parameter) of the BNN posterior
- logvar : torch.Tensor of shape [self.batch_size, self.Y_dim]
- network prediction of the log of the diagonal elements of the covariance matrix
- F : torch.Tensor of shape [self.batch_size, self.Y_dim, self.rank]
- network prediction of the low rank portion of the covariance matrix
- np.array of shape [self.batch_size, n_samples, self.Y_dim]
- samples
-
sample_full_rank(self, n_samples, mu, tril_elements)[source]¶ Sample from a single Gaussian posterior with a full-rank covariance matrix
- n_samples : int
- how many samples to obtain
- mu : torch.Tensor of shape [self.batch_size, self.Y_dim]
- network prediction of the mu (mean parameter) of the BNN posterior
- tril_elements : torch.Tensor of shape [self.batch_size, tril_len]
- network prediction of lower-triangular matrix in the log-Cholesky decomposition of the precision matrix
- np.array of shape [self.batch_size, n_samples, self.Y_dim]
- samples
-
-
class
h0rton.h0_inference.gaussian_bnn_posterior_cpu.DiagonalGaussianBNNPosteriorCPU(Y_dim, Y_mean=None, Y_std=None)[source]¶ Bases:
h0rton.h0_inference.gaussian_bnn_posterior_cpu.BaseGaussianBNNPosteriorCPUThe negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix
BaseGaussianNLL.__init__ docstring for the parameter description.
-
class
h0rton.h0_inference.gaussian_bnn_posterior_cpu.LowRankGaussianBNNPosteriorCPU(Y_dim, Y_mean=None, Y_std=None)[source]¶ Bases:
h0rton.h0_inference.gaussian_bnn_posterior_cpu.BaseGaussianBNNPosteriorCPUThe negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix
BaseGaussianNLL.__init__ docstring for the parameter description.
-
class
h0rton.h0_inference.gaussian_bnn_posterior_cpu.DoubleLowRankGaussianBNNPosteriorCPU(Y_dim, Y_mean=None, Y_std=None)[source]¶ Bases:
h0rton.h0_inference.gaussian_bnn_posterior_cpu.BaseGaussianBNNPosteriorCPUThe negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix
BaseGaussianNLL.__init__ docstring for the parameter description.
-
sample(self, n_samples, sample_seed)[source]¶ Sample from a mixture of two Gaussians, each with a full but constrained as low-rank plus diagonal covariance
- n_samples : int
- how many samples to obtain
- sample_seed : int
- seed for the samples. Default: None
- np.array of shape [self.batch_size, n_samples, self.Y_dim]
- samples
-
-
class
h0rton.h0_inference.gaussian_bnn_posterior_cpu.FullRankGaussianBNNPosteriorCPU(Y_dim, Y_mean=None, Y_std=None)[source]¶ Bases:
h0rton.h0_inference.gaussian_bnn_posterior_cpu.BaseGaussianBNNPosteriorCPUThe negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix
BaseGaussianNLL.__init__ docstring for the parameter description.
-
class
h0rton.h0_inference.gaussian_bnn_posterior_cpu.DoubleGaussianBNNPosteriorCPU(Y_dim, Y_mean=None, Y_std=None)[source]¶ Bases:
h0rton.h0_inference.gaussian_bnn_posterior_cpu.BaseGaussianBNNPosteriorCPUThe negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix
BaseGaussianNLL.__init__ docstring for the parameter description.
-
sample(self, n_samples, sample_seed)[source]¶ Sample from a mixture of two Gaussians, each with a full but constrained as low-rank plus diagonal covariance
- n_samples : int
- how many samples to obtain
- sample_seed : int
- seed for the samples. Default: None
- np.array of shape [self.batch_size, n_samples, self.Y_dim]
- samples
-