ELBOLoss¶
- class torch_uncertainty.losses.ELBOLoss(model, inner_loss, kl_weight, num_samples)[source]¶
The Evidence Lower Bound (ELBO) loss for Bayesian Neural Networks.
ELBO loss for Bayesian Neural Networks. Use this loss function with the objective that you seek to minimize as
inner_loss
.- Parameters:
model (nn.Module) – The Bayesian Neural Network to compute the loss for
inner_loss (nn.Module) – The loss function to use during training
kl_weight (float) – The weight of the KL divergence term
num_samples (int) – The number of samples to use for the ELBO loss
Note
Set the model to None if you use the ELBOLoss within the ClassificationRoutine. It will get filled automatically.