Skip to content

Newton optimizer: handle flat directions without producing NaN - #3429

Open
SteveBronder wants to merge 1 commit into
developfrom
fix/newton-flat-direction-3425
Open

Newton optimizer: handle flat directions without producing NaN#3429
SteveBronder wants to merge 1 commit into
developfrom
fix/newton-flat-direction-3425

Conversation

@SteveBronder

Copy link
Copy Markdown
Collaborator

Submission Checklist

  • Run unit tests: ./runTests.py src/test/unit
  • Run cpplint: make cpplint
  • Declare copyright holder and open-source license: see below

Summary

Fixes #3425.

make_negative_definite_and_solve divided the gradient projection by fabs(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 returns 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.

Documentation

Updated docs for make_negative_definite_and_solve to 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:

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Newton optimizer produces NaN parameters for a target with a flat direction, no error raised

1 participant