LaplaceRepresenter

class probly.method.laplace.torch.LaplaceRepresenter(predictor: BaseLaplace, num_samples: int, pred_type: str = 'glm', sampling_strategy: SamplingStrategy = 'sequential', sample_factory: SampleFactory[CategoricalDistribution, S]=<flextype.singledispatch.Flexdispatch object>, sample_axis: int = -1)[source]

Bases: Sampler[In, CategoricalDistribution, S], Generic[In, S]

Representer over BaseLaplace.predictive_samples (classification only; see laplace-torch docs).

Parameters:
  • predictor – A fitted BaseLaplace instance.

  • num_samples – Number of posterior samples to draw.

  • pred_type – Forwarded to BaseLaplace.predictive_samples; typically "glm" or "nn".

  • sampling_strategy – How repeated predictions are computed.

  • sample_factory – Factory used to build the returned Sample.

  • sample_axis – Axis along which samples are stacked in the output tensor.

Initialize the Laplace representer.

__call__(*args: In.args, **kwargs: In.kwargs) R[source]

Alias for the represent method.

num_samples
pred_type: str
predict(*args: In.args, **kwargs: In.kwargs) R[source]

Predict the representation for a given input.

predictor
represent(*args: In.args, **kwargs: In.kwargs) S[source]

Bulk-sample from the posterior and return a TorchCategoricalDistributionSample.

sample_axis
sample_factory
sampling_strategy

Examples using probly.method.laplace.torch.LaplaceRepresenter

Laplace Approximation on Two Moons

Laplace Approximation on Two Moons

Laplace on MNIST

Laplace on MNIST