tensorflow / tensorflow/probability

tfp.optim.lbfgs_minimize fails where scipy.optimize and torch.optim.LBFGS succeed for poisson optimization

Open
#637 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Jupyter Notebook
Stars
4.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

For this minimal example of fitting a 1-parameter poissonian likelihood Pois(10|par) where you would expect the best-fit value to be 10.0 tfp seems to fail:

tf.reset_default_graph()
sess = tf.Session()
def func_tf(pars):
    nll = -tfp.distributions.Poisson(pars).log_prob(10.)
    grad = tf.identity(tf.gradients(nll,pars))[0]
    return nll[0],grad

result = sess.run(tfp.optimizer.lbfgs_minimize(func_tf,tf.convert_to_tensor([1.6])))
'converged: {}, failed: {}, position: {}'.format(result.converged,result.failed,result.position)

gives:

'converged: False, failed: True, position: [11.124551]'

the optimization fails.

Interestingly it seems to be quite sensitive to the initial position. If I change the initial position to 10.5 the minimization succeeds:

result = sess.run(tfp.optimizer.lbfgs_minimize(func_tf,tf.convert_to_tensor([10.5])))
'converged: {}, failed: {}, position: {}'.format(result.converged,result.failed,result.position)
'converged: True, failed: False, position: [10.]'

As a cross-check I tried using the LBFGS optimizers in scipy.optimize and PyTorch to see if this is an issue, and in those cases the initial position 1.6 seems ok

Note: in scipy I had to cast to double precision due to: https://github.com/scipy/scipy/issues/5832

I'm attaching a screentshot of the full notebook, which is available here: https://gist.github.com/lukasheinrich/327ab8bf1b96e9af3e483a4b26d435ea

screenshot

cc @matthewfeickert @kratsg

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal notebook example through tfp.optimizer.lbfgs_minimize with initial positions 1.6 and 10.5, then compare the reported convergence, failure, and position. Trace the optimizer's behavior for the one-parameter Poisson likelihood and verify that the 1.6 case converges to the expected position of 10.0 without breaking the successful case.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.