Uncertainty Estimators¶
-
class
alpaca.ue.
UE
(net, *, nn_runs=25, keep_runs: bool = False)[source]¶ Abstract class for all uncertainty estimation method implementations
- Parameters
net (
torch.nn.Module
) – Neural network on based on which we are calculating uncertainty regionnn_runs – A number of iterations
keep_runs (bool) – Whenever to save iteration results
Examples
>>> # This could be used to create custom >>> # uncertainty estimation strategy >>> class CustomUE(UE): >>> def __init__(self, ...): >>> ... >>> def __call__(self, X_pool: torch.Tensor): >>> ... >>> estimator = CustomUE(model, ...) >>> predictions, estimations = estimator(x_batch)
-
last_mcd_runs
() → torch.Tensor[source]¶ Return model prediction for the last uncertainty estimation
-
class
alpaca.ue.
MCDUE
(*args, num_classes=0, **kwargs)[source]¶ MCDUE constructor. Depending on the provided num_classes argument, the constructor will initialize MCDUE_regression or MCDUE_classification classes.
- Other Parameters
num_classes (int) – Integer that sets the number of classes for prediction
Examples
>>> import alpaca >>> model : nn.Module = ... # define a torch nn.Model >>> model = train_model(...) # train the model >>> estimator = MCDUE(model, nn_runs=100, num_classes=10) >>> predictions, estimations = estimator(x_batch)