ncalab.uncertainty.uncertainty_estimator ======================================== .. py:module:: ncalab.uncertainty.uncertainty_estimator Classes ------- .. autoapisummary:: ncalab.uncertainty.uncertainty_estimator.UncertaintyEstimator ncalab.uncertainty.uncertainty_estimator.NQM ncalab.uncertainty.uncertainty_estimator.MCMC Module Contents --------------- .. py:class:: UncertaintyEstimator(nca: ncalab.models.AbstractNCAModel) :param nca: Trained NCA model :type nca: AbstractNCAModel .. py:attribute:: nca .. py:method:: _estimate(image: torch.Tensor) -> Tuple[torch.Tensor, List[ncalab.prediction.Prediction]] Internal uncertainty estimation method. :param image: Input image sample :type image: torch.Tensor :return: Float tensor of uncertainty heatmap (BCWH), predictions, reduced uncertainty score :rtype: Tuple[torch.Tensor, List[Prediction], float] .. py:method:: estimate(image: torch.Tensor, reduce: str = 'mean') -> Tuple[torch.Tensor, List[ncalab.prediction.Prediction], torch.Tensor] Estimate predictive uncertainty. :param image: Input image sample :type image: torch.Tensor :param reduce: Reduction strategy, defaults to "mean". :type reduce: str :return: Float tensor of uncertainty heatmap (BCWH), final prediction, reduced uncertainty score for batch (BC) :rtype: Tuple[torch.Tensor, List[Prediction], torch.Tensor] .. py:method:: __call__(*args, **kwargs) .. py:class:: NQM(nca: ncalab.models.AbstractNCAModel, N: int = 10, normalize=False) Bases: :py:obj:`UncertaintyEstimator` Variance over multiple predictions. :param nca: Trained NCA model :type nca: AbstractNCAModel .. py:attribute:: N :value: 10 .. py:attribute:: normalize :value: False .. py:method:: _estimate(image: torch.Tensor) -> Tuple[torch.Tensor, List[ncalab.prediction.Prediction]] Internal uncertainty estimation method. :param image: Input image sample :type image: torch.Tensor :return: Float tensor of uncertainty heatmap (BCWH), predictions, reduced uncertainty score :rtype: Tuple[torch.Tensor, List[Prediction], float] .. py:class:: MCMC(nca: ncalab.models.AbstractNCAModel, N_last: int = 10, normalize=False) Bases: :py:obj:`UncertaintyEstimator` Markov-Chain Monte Carlo :param nca: Trained NCA model :type nca: AbstractNCAModel .. py:attribute:: N_last :value: 10 .. py:attribute:: normalize :value: False .. py:method:: _estimate(image: torch.Tensor) -> Tuple[torch.Tensor, List[ncalab.prediction.Prediction]] Internal uncertainty estimation method. :param image: Input image sample :type image: torch.Tensor :return: Float tensor of uncertainty heatmap (BCWH), predictions, reduced uncertainty score :rtype: Tuple[torch.Tensor, List[Prediction], float]