MONAI icon indicating copy to clipboard operation
MONAI copied to clipboard

Propose fix perceptual loss sqrt nan

Open cvbourne opened this issue 8 months ago • 2 comments

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.

cvbourne avatar Apr 07 '25 15:04 cvbourne

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.

KumoLiu avatar Apr 08 '25 15:04 KumoLiu

Hi @cvbourne, could you please help resolve the DCO issue and also help take a look at the failed pipeline? Thanks.

KumoLiu avatar May 09 '25 14:05 KumoLiu