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 ExtendedImportanceSample object.

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 inputs to BoundPlate, 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.

moments()

See Moments

dump()

Returns the Importance samples as dictionary of named tensors, where the name N corresponds 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.