-
Notifications
You must be signed in to change notification settings - Fork 12
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
Robustness tests and inference helpers #38
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This will reduce emcee pooling performance (should look at this later), but restore sanity
... so we can run multiple inferences in parallel
To match what is written in the paltas paper
JelleAalbers
force-pushed
the
gaussian_inference_helper
branch
2 times, most recently
from
September 16, 2022 20:26
b33426c
to
8079dfb
Compare
(Relative imports work differently depending whether you are already in a package or not... I should know this)
JelleAalbers
force-pushed
the
gaussian_inference_helper
branch
from
September 16, 2022 20:39
8079dfb
to
4a35df6
Compare
Maybe matplotlib has become less tolerant for negative yerr recently? Can't find the PR though.
Had to move files into a paltas subdir with __init__.py. Including files outside package dir is tricky.
I moved most of this to a separate repository here https://github.com/JelleAalbers/bendorbreak, so we can close this. I might make a new PR for some of the smaller fixes in here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds support for end-to-end robustness tests.
A new script,
robustness_test.py
, allows you to quickly do the main sequence of tasks -- generate images, get predictions from a network, and run a hierarchical inference MCMC. You can run the config as-is, or specify which parts of the config to change -- e.g. set the population's sigma_sub or theta_E to a different distribution or a fixed value.The new
paltas.Analysis.gaussian_inference
file supports this with:run_network_on
function that runs a neural network over all images in a folder, rotationally averaging predictions similar to the paltas paper. The main difference is that this code rotates over a deterministic set of rotations (e.g. 0 degrees, 10 degrees, 20, etc) rather than a random set -- forn_rotations
large enough this should not matter. Results are saved in an npz in the image folder, or returned.GaussianInference
class to help coordinate hierarchical inference. You can initialize it with a folder you previously didrun_network_on
on (with.from_folder
), or just the npz it produces (with.from_npz
).GaussianInference
instances have a.bayesian_mcmc
method that runs hierarchical inference as described in the paper. Only difference is that the hyperpriors on std_[population_parameter] are uniform in [0, inf] rather than uniform in some range of log, to avoid concentrating the hyperprior at very small values. You can revert to the log prior by settinglog_sigma=True
when buildingGaussianInference
.Feel free to tell me some or all of this doesn't belong in paltas! This is probably an alternative implementation of the stuff you already have in jupyter notebooks; would be useful to compare them at some point.
Other changes
generate.py
androbustness_test.py
can now both be called through functions as well as shell commands. A small command line interface generator (inUtils.cli_maker
) takes care of this. This also simplifies some test code..cvs
and.fits
files already in the repo in the python package. On the main branch, setuptools omitsbad_galaxies.csv
etc from the wheel, since it's not listed as package data. As long as you do a developer/editable install this doesn't matter, but if you do a regular pip install this will bite you (at least when using the paper configs). I had to move the HST PSFs to somewhere underpaltas
(and add an__init__.py
to the folder); I don't think it's easy to control where data files that live outside the package get shipped. A directory symlink ensures that any old code that relies on this location still works.deepcopy
the training config'sconfig_dict
. This is a hack, and for now only supports plain scipy.stats distributions andDuplicate
distribution, not the other custom distributions paltas implements.Analysis/hierarchical_inference.py
to class attributes. The globals existed to allow the use ofmultiprocess.Pool
in the MCMC inference. I think:unnormalize
can now also unnormalize the precision matrix directly, and can be run independently for unnormalizing means and covariances