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

I1137 horowitz langevin mcmc #1138

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Conversation

DavAug
Copy link
Member

@DavAug DavAug commented May 15, 2020

Closes #1137

The algorithm is largely the same as the existing a pints.HamiltonianMCMC. I made references in the ask and tell methods where the code has been adapted.

The other change was to remove the hyper parameter leapfrog_steps and introduce a new one alpha that controls the persistence of the momentum.

@codecov
Copy link

codecov bot commented May 15, 2020

Codecov Report

Merging #1138 (59c3857) into master (31d4f27) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 59c3857 differs from pull request most recent head a8d2350. Consider uploading reports for the commit a8d2350 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##            master     #1138    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           87        81     -6     
  Lines         8936      7961   -975     
==========================================
- Hits          8936      7961   -975     
Impacted Files Coverage Δ
pints/__init__.py 100.00% <100.00%> (ø)
pints/_mcmc/_neal_langevin.py 100.00% <100.00%> (ø)
pints/_util.py 100.00% <0.00%> (ø)
pints/_logger.py 100.00% <0.00%> (ø)
pints/_log_pdfs.py 100.00% <0.00%> (ø)
pints/_evaluation.py 100.00% <0.00%> (ø)
pints/_log_priors.py 100.00% <0.00%> (ø)
pints/_mcmc/_mala.py 100.00% <0.00%> (ø)
pints/_diagnostics.py 100.00% <0.00%> (ø)
... and 43 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 31d4f27...a8d2350. Read the comment docs.

@DavAug
Copy link
Member Author

DavAug commented May 15, 2020

@MichaelClerx @chonlei @ben18785
I ran the doc builds but no documentation is generated. Any ideas?

@DavAug
Copy link
Member Author

DavAug commented May 15, 2020

To clarify:
I tried
$ python run-tests.py --quick
and also
$ cd docs and then $ make clean; make html

@chonlei
Copy link
Member

chonlei commented May 15, 2020

@DavAug I've just tried it, it seems working for me (both the master and this branch). I am using v2.4.4 for Sphinx. Have you got Sphinx installed properly? Can you try to reinstall pints with pip install -e .[dev,docs]?

@chonlei
Copy link
Member

chonlei commented May 15, 2020

Just thinking given their similarity, would it be worth to have this HorowitzLangevinMCMC inherits from the HamiltonianMCMC class...?

@DavAug
Copy link
Member Author

DavAug commented May 15, 2020 via email

Copy link
Collaborator

@ben18785 ben18785 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @DavAug looks like a really great start. My thoughts are:

  • a) let's call this sampler the ``NealLangevin'' method
  • b) let's then include a hyperparameter that allows switching on/off the non-reversible bit (i.e. changing u)

Also, could we write an example notebook that shows that this is working?

@DavAug
Copy link
Member Author

DavAug commented May 15, 2020 via email

@ben18785
Copy link
Collaborator

ben18785 commented May 15, 2020 via email

@DavAug
Copy link
Member Author

DavAug commented May 17, 2020

This is the completed NealLangevin Sampler.

  1. There does seem to be an issue with Sphinx that I can't work out. I downgraded the latest version of Sphinx to 2.4.4 to match with @chonlei, but it doesn't work. Sphinx does seem to run and it checks for the existing documentation, but there is no new documentation for the Neal Sampler generated with make clean, make html.

  2. I chose a Gaussian noise for the updating of u, which can be tuned. The noise is not specified in the paper. Do we want a less stringent solution for the noise? E.g. one could pass in a noise generating function or something?

  3. For u, delta and the noise of delta, no default initial values are provided. So I chose some and commented on it. Maybe those have to be adapted.

  4. It is not clear to me whether u should be updated for divergent transitions. At the moment it is not updated, but I tend to say that it should be updated, since in HMC we also sample a new momentum when a divergent transition occurs. I wasn't sure about the behaviour of the sampler in those cases, that's why I wanted to discuss this here.

@chonlei
Copy link
Member

chonlei commented May 18, 2020

@DavAug Besides the documentation that you have included in the Python class, you also have to include and provide a link to the docs in order to let the Sphinx knows what to link to where!

@chonlei
Copy link
Member

chonlei commented May 18, 2020

@DavAug I have added those to the docs for you, so that you don't have to find where to add this time. Remember to pull and merge before doing any updates/push.

Also if you now run the make, you will see some warming to fix for the documentation that you have in the MCMC class. Can you please fix those?

And you might want to change the title to "Neal Langenvin MCMC" instead of "Horowitz Langenvin MCMC" too!

Copy link
Collaborator

@ben18785 ben18785 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @DavAug. I haven't looked through this in detail yet but is looking good.

My thoughts are:

  • I'd be interested to hear what @MichaelClerx thinks about this but, seeing as this method is so similar to (essentially derived from) HMC, should this method be derived from that?
  • Can we have an example notebook please?

@DavAug
Copy link
Member Author

DavAug commented May 18, 2020

@chonlei Great thanks! It makes sense, but I didn't know that you had to give further instructions to Sphinx :D

@DavAug
Copy link
Member Author

DavAug commented May 18, 2020

@ben18785 Yes, I can make an example notebook.

@DavAug
Copy link
Member Author

DavAug commented May 18, 2020

I somehow don't seem to have the permission to look at codecov's analysis and see which lines where not hit. Is there something we can do about it?

@MichaelClerx
Copy link
Member

I somehow don't seem to have the permission to look at codecov's analysis and see which lines where not hit. Is there something we can do about it?

Even after you hit "Login with github" ?

@DavAug
Copy link
Member Author

DavAug commented May 18, 2020

Yes, a Github API error is thrown, but it's apparently a Safari issue. It works with Chrome.

@DavAug DavAug requested a review from ben18785 May 20, 2020 14:55
@MichaelClerx
Copy link
Member

@ben18785 @DavAug this is 99% done :D

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.

Horowitz-Langevin MCMC
4 participants