ncalab.uncertainty.uncertainty_estimator

Classes

UncertaintyEstimator

NQM

Variance over multiple predictions.

MCMC

Markov-Chain Monte Carlo

Module Contents

class ncalab.uncertainty.uncertainty_estimator.UncertaintyEstimator(nca: ncalab.models.AbstractNCAModel)
Parameters:

nca (AbstractNCAModel) – Trained NCA model

nca
_estimate(image: torch.Tensor) Tuple[torch.Tensor, List[ncalab.prediction.Prediction]]

Internal uncertainty estimation method.

Parameters:

image (torch.Tensor) – Input image sample

Returns:

Float tensor of uncertainty heatmap (BCWH), predictions, reduced uncertainty score

Return type:

Tuple[torch.Tensor, List[Prediction], float]

estimate(image: torch.Tensor, reduce: str = 'mean') Tuple[torch.Tensor, List[ncalab.prediction.Prediction], torch.Tensor]

Estimate predictive uncertainty.

Parameters:
  • image (torch.Tensor) – Input image sample

  • reduce (str) – Reduction strategy, defaults to “mean”.

Returns:

Float tensor of uncertainty heatmap (BCWH), final prediction, reduced uncertainty score for batch (BC)

Return type:

Tuple[torch.Tensor, List[Prediction], torch.Tensor]

__call__(*args, **kwargs)
class ncalab.uncertainty.uncertainty_estimator.NQM(nca: ncalab.models.AbstractNCAModel, N: int = 10, normalize=False)

Bases: UncertaintyEstimator

Variance over multiple predictions.

Parameters:

nca (AbstractNCAModel) – Trained NCA model

N = 10
normalize = False
_estimate(image: torch.Tensor) Tuple[torch.Tensor, List[ncalab.prediction.Prediction]]

Internal uncertainty estimation method.

Parameters:

image (torch.Tensor) – Input image sample

Returns:

Float tensor of uncertainty heatmap (BCWH), predictions, reduced uncertainty score

Return type:

Tuple[torch.Tensor, List[Prediction], float]

class ncalab.uncertainty.uncertainty_estimator.MCMC(nca: ncalab.models.AbstractNCAModel, N_last: int = 10, normalize=False)

Bases: UncertaintyEstimator

Markov-Chain Monte Carlo

Parameters:

nca (AbstractNCAModel) – Trained NCA model

N_last = 10
normalize = False
_estimate(image: torch.Tensor) Tuple[torch.Tensor, List[ncalab.prediction.Prediction]]

Internal uncertainty estimation method.

Parameters:

image (torch.Tensor) – Input image sample

Returns:

Float tensor of uncertainty heatmap (BCWH), predictions, reduced uncertainty score

Return type:

Tuple[torch.Tensor, List[Prediction], float]