Skip to content

Commit 26d6dee

Browse files
Add EmbeddingCollapseMetric: detect representational collapse in medi… (#8815)
…cal imaging embeddings Closes #8808 Fixes # . ### Description A few sentences describing the changes proposed in this pull request. Adds EmbeddingCollapseMetric for detecting representational collapse in embedding spaces — when class centroids converge, effective dimensionality drops, or domains become indistinguishable, even while AUROC/Dice look fine. Computes five indicators (all [0, 1], higher = more collapsed): centroid_similarity — L2-normalised class centroid cosine similarity effective_rank_score — SVD effective rank (Roy & Vetterli, 2007) per_class_rank_<cls> — per-class effective rank (asymmetric collapse) domain_shift — linear CKA between domains (Kornblith et al., 2019) separation — silhouette inter-class separation (sklearn optional) Follows FIDMetric/MMDMetric pattern: inherits Metric, tensor-in/tensor-out, torch-only core. Validated on pathology embeddings ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [x] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: ekansh-arora0 <ekansh.arora0@gmail.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
1 parent 7f6b7e5 commit 26d6dee

4 files changed

Lines changed: 904 additions & 0 deletions

File tree

docs/source/metrics.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ Metrics
158158

159159
`Fréchet Inception Distance`
160160
------------------------------
161+
`Embedding Collapse`
162+
------------------------------
163+
.. autofunction:: compute_embedding_collapse
164+
165+
.. autoclass:: EmbeddingCollapseMetric
166+
:members:
167+
161168
.. autofunction:: compute_frechet_distance
162169

163170
.. autoclass:: FIDMetric

monai/metrics/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from .calibration import CalibrationErrorMetric, CalibrationReduction, calibration_binning
1717
from .confusion_matrix import ConfusionMatrixMetric, compute_confusion_matrix_metric, get_confusion_matrix
1818
from .cumulative_average import CumulativeAverage
19+
from .embedding_collapse import EmbeddingCollapseMetric, compute_embedding_collapse
1920
from .f_beta_score import FBetaScore
2021
from .fid import FIDMetric, compute_frechet_distance
2122
from .froc import compute_fp_tp_probs, compute_fp_tp_probs_nd, compute_froc_curve_data, compute_froc_score

0 commit comments

Comments
 (0)