yamle.methods.laplace module#
- class yamle.methods.laplace.LaplaceMethod(mode, *args, **kwargs)[source]#
Bases:
MCSamplingMethodThis class implements the Laplace method.
It performs Laplace approximation in the neural network to approximate the posterior distribution.
It is important the regularisation is the L2Regularizer and the regularizer_weight is non-zero. These act as the prior distribution.
At the moment, it only supports the last_layer mode and the classification task. This is because the backpack library supports only the CrossEntropyLoss but not the GaussianNLLLoss.
- Parameters:
mode¶ (str) – The mode of the method. It can be last_layer for now.
- tasks = ['classification']#
- property hessian_computed: bool#
This property returns whether the Hessian is computed.
- load_state_dict(state_dict)[source]#
This function loads the state dictionary of the method.
- Return type:
None
- state_dict()[source]#
This function returns the state dictionary of the method.
- Return type:
Dict[str,Any]