Repository navigation
Handle zero comparison images in SIMSE - #153
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #152.
Problem
simse(a, b)fits a scalar multiplier forbusing(a · b) / (b · b). Ifbis all zeros, this becomes0 / 0. As a result, entirely finite image pairs returnNaN, and JAX differentiation can produce non-finite gradients. In a batch, one zero reference image affects its own metric value even when other images are valid.Change
Treat a zero comparison norm as a defined special case: every scaled version of an all-zero image remains zero, so the optimal predicted image is zero and SIMSE equals
mean(a**2). Use a safe denominator and a conditional scale to avoid division by zero in both forward and reverse-mode calculations.The nonzero-norm path still uses the original least-squares scale. The existing
ignore_nans=Truebehaviour is preserved, includingNaNwhere no valid pixel pairs exist. Document the zero-image result in the function docstring.Validation
master.git diff --checkpass.Scope
The zero-norm branch assigns a finite result and gradient convention at this degenerate point. It does not change the metric's scale-invariance formula for nonzero references. TensorFlow-dependent test modules were not run locally.