Newton optimizer: handle flat directions without producing NaN - #3429
Open
SteveBronder wants to merge 1 commit into
Open
Newton optimizer: handle flat directions without producing NaN#3429SteveBronder wants to merge 1 commit into
SteveBronder wants to merge 1 commit into
Conversation
Fixes #3425. make_negative_definite_and_solve divided the gradient projection by fabs(eigenvalue) with no zero guard. For a target that is flat along a direction the gradient and Hessian are both zero, so the step was 0/0 and the resulting NaN parameters were accepted by the line search and reported by the service as a successful run. - Drop eigen-directions whose magnitude is negligible relative to the largest eigenvalue, as in a pseudo-inverse, so the step is finite. - Reject non-finite step directions, candidate points, and objective values in newton_step instead of accepting them. - Have the newton service return error_codes::SOFTWARE with TERM_LSFAIL when the final log density or parameters are not finite. Adds a flat_target test model plus unit tests at the solve, step, and service layers that reproduce the reported NaN.
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.
Submission Checklist
./runTests.py src/test/unitmake cpplintSummary
Fixes #3425.
make_negative_definite_and_solvedivided the gradient projection byfabs(eigenvalue)with no guard against zero or near zero values. This could lead to some directions of the gradient and hessian being flat and causing NaN values to return. Now we check that the absolute of the eigen value is greater than a tolerance defined by the an epsilon scaled by the overall maximum eigenvalue. We reject non-finite step directions, candidate points, and objective values in newton_step instead of accepting them. And the newton service layer not returnserror_codes::SOFTWAREwithTERM_LSFAILwhen the final log density or parameters are not finite.Adds a
flat_targettest model plus unit tests at the solve, step, and service layers that reproduce the reported NaN.Documentation
Updated docs for
make_negative_definite_and_solveto reflect the change.Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Steve Bronder
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: