← Lab
dicew2
confirmedupstream bugPython · korniaSystems & data structuresJuly 25, 2026
the question
Does kornia's dice_loss apply the per-class weight coherently under the default average='micro'?
what came out
kornia's dice_loss with average='micro' folds the weight into both pred and target maps before the intersection product, so weight enters the numerator squared and the denominator once. The score scales linearly with weight: a uniform weight is no longer a no-op and weight>2 drives the loss below zero. The macro sibling is correct.
method & receipts
- Result: confirmed
- Reproducible — one script re-runs the whole thing from scratch.
- Tested — a correctness/benchmark suite ships alongside the code.
→ read the code and re-run it
github.com/v-code01/dicew2