Repository navigation
Conversation
Part of Project-MONAI#5207. MCDropoutInferer wraps any inferer and runs it num_samples times with only the network's dropout layers in training mode, restoring their modes afterwards. compute_uncertainty_decomposition and UncertaintyDecompositionMetric split the uncertainty of repeated probability predictions into total (predictive entropy), aleatoric (expected entropy) and epistemic (mutual information) parts, with the repeat-first convention and reductions of VarianceMetric. Signed-off-by: eliem08 <emssaadelias@gmail.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #5207. Opened as a draft to get feedback on the API before polishing; happy to rename or move things.
Description
The 2022 discussion in #5207 concluded that test-time augmentation needs an Engine, because it re-runs transforms per subject. Monte Carlo dropout does not, so this adds it as a thin inferer, plus a way to decompose the resulting uncertainty:
monai.inferers.MCDropoutInferer(inferer=None, num_samples=10, return_samples=True)SimpleInferer, composes withSlidingWindowInferer);nn.modules.dropout._DropoutNd) to train mode, so normalization layers keep their eval behaviour, and restores every dropout layer's mode afterwards, also on error;return_samples=Falseso it can be an evaluator'sinferer;monai.metrics.compute_uncertainty_decomposition/UncertaintyDecompositionMetric, next toVarianceMetricand with the same repeat-first[N, C, ...]input,spatial_mapandscalar_reductionconventions, returnH[E_n p_n]E_n H[p_n]total - aleatoric(Depeweg et al., ICML 2018).They work on samples from MC dropout,
TestTimeAugmentation(return_full_data=True)or an ensemble.Checked end to end with
UNet(..., dropout=0.2)andSlidingWindowInfereron a 48³ volume: samples(8, 1, 3, 48, 48, 48), per-voxel maps(48, 48, 48), all modules back in eval mode afterwards.Questions for reviewers:
active_learning_metrics.pythe right home for the decomposition, givenVarianceMetricis there?Types of changes
docs/source/inferers.rst,docs/source/metrics.rst).Tests
tests/metrics/test_compute_uncertainty_decomposition.py: analytic cases (identical confident samples give zero uncertainty everywhere; disagreeing confident samples give total = epistemic = ln 2, aleatoric 0; uniform samples give total = aleatoric = ln 2, epistemic 0), total = aleatoric + epistemic, reductions, metric class vs function, invalid inputs.tests/inferers/test_mc_dropout_inferer.py: samples vary, BatchNorm running stats unchanged, modes restored (also on error), mean mode,SlidingWindowInfererwrapping, invalid arguments.test_compute_variance,test_label_quality_score, saliency and slice inferer tests: 48 passed.black,isortandruffpass.I prepared this with AI assistance and have reviewed it; I work on uncertainty estimation for breast cancer pathology.