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)
h0rton.h0_inference.gaussian_bnn_posterior_cpu.sigmoid(x)[source]
h0rton.h0_inference.gaussian_bnn_posterior_cpu.logsigmoid(x)[source]
class h0rton.h0_inference.gaussian_bnn_posterior_cpu.BaseGaussianBNNPosteriorCPU(Y_dim, Y_mean=None, Y_std=None)[source]

Bases: abc.ABC

Abstract base class to represent the Gaussian BNN posterior

Gaussian posteriors or mixtures thereof with various forms of the covariance matrix inherit from this class.

seed_samples(self, sample_seed)[source]

Seed the sampling for reproducibility

sample_seed : int

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
get_hpd_interval(self)[source]

Get the highest posterior density (HPD) interval

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.BaseGaussianBNNPosteriorCPU

The negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix

BaseGaussianNLL.__init__ docstring for the parameter description.

set_sliced_pred(self, pred)[source]
sample(self, n_samples, sample_seed)[source]

Sample from a Gaussian posterior with diagonal covariance matrix

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
get_hpd_interval(self)[source]

Get the highest posterior density (HPD) interval

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.BaseGaussianBNNPosteriorCPU

The negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix

BaseGaussianNLL.__init__ docstring for the parameter description.

set_sliced_pred(self, pred)[source]
sample(self, n_samples, sample_seed)[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
get_hpd_interval(self)[source]

Get the highest posterior density (HPD) interval

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.BaseGaussianBNNPosteriorCPU

The negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix

BaseGaussianNLL.__init__ docstring for the parameter description.

set_sliced_pred(self, pred)[source]
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
get_hpd_interval(self)[source]

Get the highest posterior density (HPD) interval

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.BaseGaussianBNNPosteriorCPU

The negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix

BaseGaussianNLL.__init__ docstring for the parameter description.

set_sliced_pred(self, pred)[source]
sample(self, n_samples, sample_seed)[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
get_hpd_interval(self)[source]

Get the highest posterior density (HPD) interval

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.BaseGaussianBNNPosteriorCPU

The negative log likelihood (NLL) for a single Gaussian with diagonal covariance matrix

BaseGaussianNLL.__init__ docstring for the parameter description.

set_sliced_pred(self, pred)[source]
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
get_hpd_interval(self)[source]

Get the highest posterior density (HPD) interval