Importance Sample
- class alan.ImportanceSample[source]
Constructed by calling
Sample.importance_sample. Represents N joint samples in the latent space.- extend(extended_platesizes: dict[str, int], extended_inputs=None)[source]
Does prediction by:
taking a posterior sample, represented by the ImportanceSample object.
extending the plate sizes.
sampling the extra latent variables from the prior.
It returns an
ExtendedImportanceSampleobject.- Parameters:
extended_platesizes (dict[str, int]) – A dictionary mapping the platename to the extended platesize. Must be the same as or bigger than the platesizes in the underlying model.
extended_inputs (dict[str, torch.Tensor]) – If the model has any e.g. features given as
inputstoBoundPlate, then the extended versions of these inputs must be provided here.
Note
Won’t work if P has any plated parameters, as these won’t be extended.
- dump()
Returns the Importance samples as dictionary of named tensors, where the name
Ncorresponds to the different samples, and the other names correspond to plates.Warning
You shouldn’t really need to use this method. e.g. if you’re trying to compute moments you should directly use the dump method.