Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use L-BFGS due to the closure argument #1674

Closed
MrHuff opened this Issue Dec 17, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@MrHuff
Copy link

MrHuff commented Dec 17, 2018

Issue Description

When doing:

optim = pyro.optim.PyroOptim(torch.optim.LBFGS,{})
svi = SVI(model, guide, optim, loss=Trace_ELBO(), num_samples=1000)

for some model and guide I specified according to the Bayesian Regression I can't run svi.step(...).

Environment

  • OS and python version: Fedora 29, 3.6.7
  • PyTorch version: 1.0 (stable release)
  • Pyro version: 0.3.0

Code Snippet

When running the code (i.e. svi.step(...)) I get the following error:

Traceback (most recent call last):
File "C:/Users/Robert/Documents/phd_projects/retail_asq_allo/test.py", line 91, in
loss = svi.step((rows,cols), ratings)
File "C:\Users\Robert\Miniconda3\envs\allo_env\lib\site-packages\pyro\infer\svi.py", line 106, in step
self.optim(params)
File "C:\Users\Robert\Miniconda3\envs\allo_env\lib\site-packages\pyro\optim\optim.py", line 58, in call
self.optim_objs[p].step(*args, **kwargs)
TypeError: step() missing 1 required positional argument: 'closure'

Process finished with exit code 1

My hypothesis is that it's the L-BFGS that makes things tricky with the closure argument:

    # torch.optim objects gets instantiated for any params that haven't been seen yet
    self.optim(params)

I would greatly appreciate any help on this or any advice on how to proceed.

Thank you!

Best regards,
Robert

@MrHuff MrHuff changed the title Can't use L-BFGS due to the closure argument step Can't use L-BFGS due to the closure argument Dec 17, 2018

@fehiepsi

This comment has been minimized.

Copy link
Collaborator

fehiepsi commented Dec 17, 2018

For an example of using LBFGS, you can take a look at this method. Please also take a look at Custom SVI Objectives tutorial for better understanding.

@MrHuff

This comment has been minimized.

Copy link
Author

MrHuff commented Dec 17, 2018

Thanks a lot @fehiepsi

@eb8680

This comment has been minimized.

Copy link
Member

eb8680 commented Dec 17, 2018

Closing as duplicate of #1519

@eb8680 eb8680 closed this Dec 17, 2018

@eb8680 eb8680 added the question label Dec 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.