PyAutoFit icon indicating copy to clipboard operation
PyAutoFit copied to clipboard

Infinite search_direction in line_search

Open rhayes777 opened this issue 3 years ago • 2 comments

Some of the values in search_direction become infinite resulting in bad values being passed to the fit.

Here's the offending search_direction:

VariableData({<UniformPrior id=43 lower_limit=0.01 upper_limit=0.5>: -inf, <UniformPrior id=44 lower_limit=0.1 upper_limit=0.5>: -inf, <LogUniformPrior id=5 lower_limit=0.01 upper_limit=0.5>: 14.556109976510278})

This seems to be due to the newton_direction function. The gradient of the state passed to this function does not contain infinities:

VariableData({<class 'autofit.mapper.variable.FactorValue'>: 1.0, <UniformPrior id=43 lower_limit=0.01 upper_limit=0.5>: -1.5785864615480705, <UniformPrior id=44 lower_limit=0.1 upper_limit=0.5>: -2.5857528340722644, <LogUniformPrior id=5 lower_limit=0.01 upper_limit=0.5>: 5.747277708563938})

However, the log determinant of the hessian (VariableFullOperator) is -inf so this might be where the issue is coming from.

rhayes777 avatar Apr 06 '22 08:04 rhayes777

Hmm, the Hessian here has become indefinite, so its inverse isn't finite. We probably need some code to force the Hessian to be positive-definite. The challenge with that is that we'd define a hyperparameter that enforces some maximum curvature on the problem e.g. 1/eps.

matthewghgriffiths avatar Apr 06 '22 09:04 matthewghgriffiths

Could either create a modified full_diag_update routine - https://github.com/rhayes777/PyAutoFit/blob/5721dc8585ce2da80f90f7b18ece6dfd6f181f2e/autofit/graphical/laplace/newton.py#L216 - that enforces PD on the updated Hessian

or create a posdef_hessian_direction function that forces the Hessian to be positive definite.

matthewghgriffiths avatar Apr 06 '22 09:04 matthewghgriffiths