Always copy the final point found by scipy #2047
Merged
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.
PR type: bugfix
Summary
We have observed some instability during model training, where occasionally the SGPR model loss is unexpectadly very poor. We have tracked the problem down to how the gpflow wrapper calls the scipy optimiser (using BFGS in our case).
The wrapper uses
tf.Variable
s for the model hyperparameters and these are updated on every evaluation of the training loss. On those occasions where the BFGS line-search fails for an iteration, the scipy optimiser returns the previous good point that it found and sets appropriate flags in theOptimizeResult
class. However, the model hyperparameters will have the value of the last evaluation of the failed line-search, which can be quite poor. One solution is for the caller to look at the returned result, realise that there was a fail and copy over the final point fromOptimizeResult
back to the model hyperparameters. However it's perhaps better for the wrapper to always copy the final scipy optimiser point to the model just before returning.Proposed changes
What alternatives have you considered?
Minimal working example
# Put your example code in here
Release notes
Fully backwards compatible: yes / no
If not, why is it worth breaking backwards compatibility:
PR checklist
make format
)make check-all
)