Repository navigation
Use an overflow-free analysis-confidence sigmoid - #11
Merged
peterdsharpe merged 1 commit intoSep 26, 2026
Merged
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.
Summary
Replace the clipped exponential form of the analysis-confidence sigmoid with the mathematically equivalent overflow-free form
and add a public-API regression test that evaluates a vectorized case far outside the training distribution and checks that both the forward values and CasADi MX reverse derivatives remain finite.
Context
In NeuralFoil 0.2.2, sufficiently negative confidence logits can overflow
exp(-x). The forward aerodynamic outputs remain finite, but the overflowing node can contaminate an MX reverse sweep with0 * inf, producing NaN derivatives.Current
masteralready prevents the reproducer from failing by clipping the sigmoid input. Thetanhform removes the overflowing exponential path and the float64-derived clipping constants altogether while preserving the sigmoid values to floating-point precision over the active range.Validation
python -m pytest tests -q: 32 passed.The regression case produces non-finite MX reverse entries at indices 5, 6, and 7 with the installed NeuralFoil 0.2.2, and finite forward and reverse values with this change. The two sigmoid forms differ by at most
2.22e-16over 20,001 points on[-40, 40].Fixes #10.