jiwoncpark / h0rton

Deep Modeling of Strong Gravitational Time Delay Lenses for Bayesian Inference of the Hubble Constant
MIT License
10 stars 1 forks source link

Issue/8 #20

Closed jiwoncpark closed 4 years ago

jiwoncpark commented 4 years ago

What this PR adds This PR is for merging #8, which implements and tests three BNN posterior classes DiagonalGaussianBNNPosterior, LowRankGaussianBNNPosterior and DoubleGaussianBNNPosterior inheriting from the abstract base class BaseGaussianBNNPosterior. The names are long because we expect to add non-Gaussian forms of the posterior, e.g. multidimensional gamma, in the future.

Design An instantiation of each BNN posterior class represents a batch of BNN posteriors. It comes with a sampling method, self.sample(n_samples, sampling_seed). We want to be able to sample from the BNN posteriors of many lenses at a time, and the batch sampling parallelizes across multiple lenses.

I've also left placeholders for the highest posterior density interval evaluation, self.get_hpd_interval(), which I'll tackle in a different issue. The evaluation is analytical for a single Gaussian but numerical for multiple Gaussians.

jiwoncpark commented 4 years ago

I'll merge with master for now but please feel free to leave comments whenver!

jiwoncpark commented 4 years ago

Thank you! True... I've been ignoring Travis since I'm planning to overhaul the training code (to make it more readable) and I didn't know which release of torch I should be testing with (since this depends on the GPU version). I ran the tests locally (python setup.py test) and all seven pass.

I actually don't think Travis can configure GPUs, so I'll just have it download a CPU version of torch! And there were some rawstring formatting errors.

As for coveralls, on it!

jiwoncpark commented 4 years ago

@sibirrer Travis builds with torch CPU and Coveralls is configured now. More tests planned to bring up the coverage from 53%...

sibirrer commented 4 years ago

awesome! :)

drphilmarshall commented 4 years ago

Good stuff, Ji Won. Good idea to enable parallelized sampling :-) My main comment is not to worry about the interval calculation: my suggestion would be to draw samples and then use corner.py to make plots and compute intervals. I think it's enough for h0rton to produce samples: its work is done, having characterized the joint posterior PDF.

I noted the review request: most likely this will come in the form of new issues made when I try to read and run the notebooks and code.