altar.cuda.models.cudaBayesian
Module Contents
Classes
- class altar.cuda.models.cudaBayesian.cudaBayesian(name, locator, **kwds)
Bases:
altar.models.Bayesian.BayesianThe base class of AlTar models that are compatible with Bayesian explorations
- 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)
- forwardonly
- doc = whether to run the simulation or the forward problem only
- theta_input
- doc = the theta input file with a vector of parameters
- theta_dataset
- doc = the name/path of the theta dataset in h5 file
- forward_output
- dpc = the name/path of the file to save forward problem results
- observations
- device
- precision
- ifs
- gidx_map
- gtheta
- initialize(self, application)
Initialize the state of the model given an {application} context
- cuInitialize(self, application)
cuda interface
- posterior(self, application)
Sample my posterior distribution
- cuInitSample(self, theta)
Fill {theta} with an initial random sample from my prior distribution.
- cuVerify(self, theta, 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
- cuEvalPrior(self, theta, prior, batch)
Fill {priorLLK} with the log likelihoods of the samples in {theta} in my prior distribution
- cuEvalLikelihood(self, theta, likelihood, batch)
calculate data likelihood and add it to step.prior or step.data
- cuEvalPosterior(self, step, batch)
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, batch=None)
Convenience function that computes all three likelihoods at once given the current {step} of the problem
- 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
- 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 numpy array (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 numpy.array
- loadFileToGPU(self, filename, shape=None, dataset=None, out=None, dtype=None)
Load an input file to a gpu (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:
out altar.cuda.matrix/vector
- restricted(self, theta, batch)
extract theta which contains model’s own parameters
- forwardProblem(self, application, theta=None)
Perform the forward modeling with given {theta}