altar.models.BayesianL2
Module Contents
Classes
- class altar.models.BayesianL2.BayesianL2(name, locator, **kwds)
Bases:
altar.models.Bayesian.BayesianA (Simplified) Bayesian Model with ParameterSets and L2 data norm
- parameters
- doc = the number of model degrees of freedom
- cascaded
- doc = whether the model is cascaded (annealing temperature is fixed at 1)
- embedded
- doc = whether the model is embedded in an ensemble of models
- psets_list
- doc = list of parameter sets, used to set orders
- psets
- default
- doc = an ensemble of parameter sets in the model
- dataobs
- default
- doc = observed data
- case
- doc = the directory with the input files
- idx_map
- default
- doc = the indices for model parameters in whole theta set
- return_residual
- doc = the forward model returns residual(True) or prediction(False)
- observations
- device
- precision
- ifs
- initialize(self, application)
Initialize the state of the model given an {application} context
- posterior(self, application)
Sample my posterior distribution
- initializeSample(self, step)
Fill {step.θ} with an initial random sample from my prior distribution.
- verify(self, step, mask)
Check whether the samples in {step.theta} are consistent with the model requirements and update the {mask}, a vector with zeroes for valid samples and non-zero for invalid ones
- evalPrior(self, theta, prior)
Fill {priorLLK} with the log likelihoods of the samples in {theta} in my prior distribution
- abstract forwardModel(self, theta, prediction)
The forward model for a single set of parameters
- forwardModelBatched(self, theta, prediction)
The forward model for a batch of theta: compute prediction from theta also return {residual}=True, False if the difference between data and prediction is computed
- evalDataLikelihood(self, theta, likelihood)
calculate data likelihood and add it to step.prior or step.data
- evalPosterior(self, step)
Given the {step.prior} and {step.data} likelihoods, compute a generalized posterior using {step.beta} and deposit the result in {step.post}
- likelihoods(self, annealer, step)
Convenience function that computes all three likelihoods at once given the current {step} of the problem
- updateModel(self, annealer)
Update Model parameters if needed :param annealer: :return: default is False
- mountInputDataspace(self, pfs)
Mount the directory with my input files
- loadFile(self, filename, shape=None, dataset=None, dtype=None)
Load an input file to a gsl vector or matrix (for both float32/64 support) Supported format: 1. text file in ‘.txt’ suffix, stored in prescribed shape 2. binary file with ‘.bin’ or ‘.dat’ suffix,
the precision must be same as the desired gpuprecision, and users must specify the shape of the data
- (preferred) hdf5 file in ‘.h5’ suffix (preferred)
the metadata of shape, precision is included in .h5 file
- Parameters:
filename – str, the input file name
shape – list of int
dataset – str, name/key of dataset for h5 input only
- Returns:
output gsl vector/matrix
- restrict(self, theta)
Return my portion of the sample matrix {theta}