MONAI
MONAI copied to clipboard
Propose fix perceptual loss sqrt nan
Fixes # 8412
Description
This PR fixes a numerical stability issue in the PerceptualLoss implementation where the normalize_tensor function can produce NaN gradients when the input values are very small.
- Moved epsilon inside the square root calculation instead of after it
- Increased default from 1e-10 to 1e-8 for better stability
- Added test
Types of changes
- [x] Non-breaking change (fix or new feature that would not break existing functionality).
- [x] New tests added to cover the changes.
- [x] Integration tests passed locally by running
./runtests.sh -f -u --net --coverage. - [x] Quick tests passed locally by running
./runtests.sh --quick --unittests --disttests.
Thanks for the update, the changes looks fine to me. Could you please help fix the failed checks then I could trigger the blossom tests? Thanks.
Hi @cvbourne, could you please help resolve the DCO issue and also help take a look at the failed pipeline? Thanks.