Project-MONAI / Project-MONAI/tutorials
AverageMeter and Metric Reduction Clarification
Personne n'a encore pris cette issue.
- Langage dominant
- Jupyter Notebook
- Étoiles
- 2.5k
- Forks
- 803
- Merge moyen
- 6 j 22 h
- PR mergées (30 j)
- 3
Description
I am seeking clarification on the AverageMeter and metric reduction implementations in 3d_segmentation/swin_unetr_brats21_segmentation_3d.ipynb.
For instance, here is the AverageMeter implementation provided in the brats swinunetr tutorial:
class AverageMeter(object):
def __init__(self):
self.reset()
def reset(self):
self.val = 0
self.avg = 0
self.sum = 0
self.count = 0
def update(self, val, n=1):
self.val = val
self.sum += val * n
self.count += n
self.avg = np.where(self.count > 0, self.sum / self.count, self.sum)
It's similar to the ImageNet implementation apart from the last line.
ImageNet's last line: self.avg = self.sum / self.count
The reason why I think this could be problematic is because the tutorial does the following:
acc_func(y_pred=val_output_convert, y=val_labels_list)
acc, not_nans = acc_func.aggregate()
run_acc.update(acc.cpu().numpy(), n=not_nans.cpu().numpy())
This implies that anytime the model has a nan prediction and the ground truth is NOT NAN (or vice versa), the resulting dice coefficient is NOT penalized as though the prediction has a dice coefficient of zero.
For instance, let's assume the ground truth is has pixels in it, but the model predicts nothing for one class, resulting in these dice values: [0.0000, 0.8775, 0.1213]
The way that AverageMeter is currently used might simply ignore the 0 dice value in the first class if DiceMetric returned nan for the corresponding class.
However, NaNs are caused by the ground truth being NaN. What happens when the ground truth is NaN AND the predicted is not NaN, because that is also not desirable (i.e. false positive)?
Edit: please see my next comment for further clarification.
To Reproduce
Just run the notebook or use the AverageMeter implementation within your own code.
Expected behavior
Would it be possible to refactor the aggregation/average meter to yield zero if the ground truth is NaN and the predicted is NOT NaN?
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par 3d_segmentation/swin_unetr_brats21_segmentation_3d.ipynb, en examinant l’implémentation de AverageMeter, l’agrégation de acc_func et l’appel à run_acc.update. Exécutez le notebook ou la reproduction indiquée et vérifiez comment les combinaisons de prédictions et de valeurs ground truth NaN et non-NaN affectent la moyenne rapportée ; le travail est terminé lorsque le comportement attendu pour les faux positifs et les classes manquantes est clarifié et reflété de manière cohérente.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- jupyter-notebook, python, pytorch
- Domaine
- machine-learning
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100