DEUP#

class torch_uncertainty.post_processing.DEUP(task, model=None, num_folds=5, hidden_dim=64, max_epochs=40, lr=0.001, device=None)[source]#

Direct Epistemic Uncertainty Prediction (DEUP).

Trains an error predictor g on out-of-fold generalization errors collected from a calibration set, following Algorithm 2 in Lahlou et al. (2023).

forward returns per-sample epistemic uncertainty estimates (non-negative). Pair with DEUPCriterion for OOD detection in ClassificationRoutine.

Parameters:
  • task (Literal['classification', 'regression']) – "classification" (per-sample cross-entropy error) or "regression" (squared error).

  • model (Module | None) – Base model producing logits or point predictions.

  • num_folds (int) – Number of cross-validation folds for OOF error collection.

  • hidden_dim (int) – Hidden width of the error predictor MLP.

  • max_epochs (int) – Training epochs for each error-predictor fit.

  • batch_size – Mini-batch size for error-predictor training. Defaults to 256.

  • lr (float) – Adam learning rate for the error predictor.

  • device (device | str | None) – Device for tensors and the error predictor.

  • progress – Show progress bars during fit.

References

Lahlou et al. (2023). DEUP: Direct Epistemic Uncertainty Prediction. TMLR. https://openreview.net/forum?id=eGLdVRvvfQ

Note

General-purpose / time-series DEUP (purged walk-forward, finance presets) lives in ursinasanderink/deup.

fit(dataloader)[source]#

Fit the error predictor on OOF errors from the calibration loader.

Return type:

None

forward(inputs)[source]#

Return epistemic uncertainty g(x) >= 0 for each sample.

Return type:

Tensor

predict_proba(inputs)[source]#

Base-model probabilities (classification only; unchanged by DEUP).

Return type:

Tensor