qpytorch.priors

QPyTorch prior objects are ported from GPyTorch excepted those highlighted.

Prior

class qpytorch.priors.Prior(batch_shape=torch.Size([]), event_shape=torch.Size([]), validate_args=None)[source]

Base class for Priors in GPyTorch. In GPyTorch, a parameter can be assigned a prior by passing it as the prior argument to register_parameter(). GPyTorch performs internal bookkeeping of priors, and for each parameter with a registered prior includes the log probability of the parameter under its respective prior in computing the Marginal Log-Likelihood.

Parameters:
log_prob(x)[source]
Returns:

log-probability of the parameter value under the prior

Return type:

torch.Tensor

Standard Priors

GammaPrior

class qpytorch.priors.GammaPrior(concentration, rate, validate_args=False, transform=None)[source]

Gamma Prior parameterized by concentration and rate

pdf(x) = beta^alpha / Gamma(alpha) * x^(alpha - 1) * exp(-beta * x)

were alpha > 0 and beta > 0 are the concentration and rate parameters, respectively.

HalfCauchyPrior

class qpytorch.priors.HalfCauchyPrior(scale, validate_args=None, transform=None)[source]

Half-Cauchy prior.

LKJCovariancePrior

class qpytorch.priors.LKJCovariancePrior(n, eta, sd_prior, validate_args=False)[source]

LKJCovariancePrior combines an LKJ prior over the correlation matrix and a user-specified prior over marginal standard deviations to return a prior over the full covariance matrix.

Usage: LKJCovariancePrior(n, eta, sd_prior), where

n is a positive integer, the size of the covariance matrix, eta is a positive shape parameter for the LKJPrior over correlations, and sd_prior is a scalar Prior over nonnegative numbers, which is used for each of the n marginal standard deviations on the covariance matrix.

MultivariateNormalPrior

class qpytorch.priors.MultivariateNormalPrior(loc, covariance_matrix=None, precision_matrix=None, scale_tril=None, validate_args=False, transform=None)[source]

Multivariate Normal prior

pdf(x) = det(2 * pi * Sigma)^-0.5 * exp(-0.5 * (x - mu)’ Sigma^-1 (x - mu))

where mu is the mean and Sigma > 0 is the covariance matrix.

cpu()[source]

Applies module-level cpu() call and resets all lazy properties

cuda(device=None)[source]

Applies module-level cuda() call and resets all lazy properties

MultivariateQExponentialPrior

class qpytorch.priors.MultivariateQExponentialPrior(mean, covariance_matrix, power=tensor(1.), validate_args=False, transform=None)[source]

Multivariate Q-Exponential prior

pdf(x) = q/2 * det(2 * pi * Sigma)^-0.5 * r^((q/2-1)*d/2) * exp(-0.5 * r^(q/2)), r = (x - mu)’ Sigma^-1 (x - mu)

where mu is the mean and Sigma > 0 is the covariance matrix.

cpu()[source]

Applies module-level cpu() call and resets all lazy properties

cuda(device=None)[source]

Applies module-level cuda() call and resets all lazy properties

NormalPrior

class qpytorch.priors.NormalPrior(loc, scale, validate_args=False, transform=None)[source]

Normal (Gaussian) Prior

pdf(x) = (2 * pi * sigma^2)^-0.5 * exp(-(x - mu)^2 / (2 * sigma^2))

where mu is the mean and sigma^2 is the variance.

QExponentialPrior

class qpytorch.priors.QExponentialPrior(loc, scale, power=tensor(1.), validate_args=False, transform=None)[source]

QExponential Prior

pdf(x) = q/2 * (2 * pi * sigma^2)^-0.5 * |(x - mu)/sigma|^(q/2-1) * exp(-0.5*|(x - mu)/sigma|^q)

where mu is the mean and sigma^2 is the variance.

SmoothedBoxPrior

class qpytorch.priors.SmoothedBoxPrior(a, b, sigma=0.01, validate_args=False, transform=None)[source]

A smoothed approximation of a uniform prior.

Has full support on the reals and is differentiable everywhere.

\[\begin{equation*} B = {x: a_i <= x_i <= b_i} d(x, B) = min_{x' in B} |x - x'| pdf(x) \sim exp(- d(x, B)**2 / sqrt(2 * sigma^2)) \end{equation*}\]