Model

class viabel.Model(log_density)[source]

Base class for representing a model.

Does not support tempering. It can be overridden in part or in whole by classes that inherit it. See StanModel for an example.

Attributes:
supports_tempering

Whether the model supports tempering.

Methods

__call__(model_param)

Compute (unnormalized) log density of the model.

constrain(model_param)

Construct dictionary of constrained parameters.

set_inverse_temperature(inverse_temp)

If tempering supported, set inverse temperature.

__call__(model_param)[source]

Compute (unnormalized) log density of the model.

Parameters:
model_paramnumpy.ndarray, shape (dim,)

Model parameter value

Returns:
log_densityfloat
__init__(log_density)[source]
Parameters:
log_densityfunction

Function for computing the (unnormalized) log density of the model. Must support automatic differentiation with autograd.

constrain(model_param)[source]

Construct dictionary of constrained parameters.

Parameters:
model_paramnumpy.ndarray, shape (dim,)

Model parameter value

Returns:
constrained_paramsdict
Raises:
NotImplementedError

If constrained parameterization is not supported.

set_inverse_temperature(inverse_temp)[source]

If tempering supported, set inverse temperature.

Parameters:
inverse_tempfloat
Raises:
NotImplementedError

If tempering is not supported.