Home

Awesome

jax-cosmo

Join the chat at https://gitter.im/DifferentiableUniverseInitiative/jax_cosmo Documentation Status CI Test black PyPI Contributor Covenant PyPI - License <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> All Contributors

<!-- ALL-CONTRIBUTORS-BADGE:END --> <h3 align="center">Finally a differentiable cosmology library, and it's in JAX!</h3>

Have a look at the GitHub issues to see what is needed or if you have any thoughts on the design, and don't hesitate to join the Gitter room for discussions.

TL;DR

This is what jax-cosmo aims to do:

...
def likelihood(cosmo):
  # Compute mean and covariance of angular Cls, for specific probes
  mu, cov = jax_cosmo.angular_cl.gaussian_cl_covariance_and_mean(cosmo, ell, probes)
  # Return likelihood value
  return jax_cosmo.likelihood.gaussian_log_likelihood(data, mu, cov)

# Compute derivatives of the likelihood with respect to cosmological parameters
g = jax.grad(likelihood)(cosmo)

# Compute Fisher matrix of cosmological parameters
F = - jax.hessian(likelihood)(cosmo)

This is how you can compute gradients and hessians of any functions in jax-cosmo, all of this without any finite differences.

Check out a full example here: colab link

Have a look at the design document to learn more about the structure of the code.

What is JAX?

JAX = NumPy + autodiff + GPU

JAX is a framework for automatic differentiation (like TensorFlow or PyTorch) but following the NumPy API, and using the GPU/TPU enable XLA backend.

What does that mean?

Checkout the JAX project page to learn more!

Install

jax-cosmo is pure Python, so installing is a breeze:

$ pip install jax-cosmo

Philosophy

Here are some of the design guidelines:

Contributing

jax-cosmo aims to be a community effort, contributions are most welcome and can come in several forms

You can chime-in on any aspects of the design by proposing a PR to the design document. The issue page is a good place to start, but don't hesitate to come chat in the Gitter room.

Please take a look at the Contributing Document for more information.

This project follows the All Contributors guidelines aiming at recognizing and valorizing contributions at any levels.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tr> <td align="center"><a href="http://flanusse.net"><img src="https://avatars0.githubusercontent.com/u/861591?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Francois Lanusse</b></sub></a><br /><a href="https://github.com/DifferentiableUniverseInitiative/jax_cosmo/commits?author=EiffL" title="Code">πŸ’»</a></td> <td align="center"><a href="http://www.cosmostat.org/people/santiago-casas"><img src="https://avatars0.githubusercontent.com/u/6987716?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Santiago Casas</b></sub></a><br /><a href="https://github.com/DifferentiableUniverseInitiative/jax_cosmo/issues?q=author%3Asantiagocasas" title="Bug reports">πŸ›</a> <a href="https://github.com/DifferentiableUniverseInitiative/jax_cosmo/commits?author=santiagocasas" title="Code">πŸ’»</a></td> <td align="center"><a href="https://github.com/austinpeel"><img src="https://avatars0.githubusercontent.com/u/17024310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Austin Peel</b></sub></a><br /><a href="https://github.com/DifferentiableUniverseInitiative/jax_cosmo/commits?author=austinpeel" title="Code">πŸ’»</a></td> <td align="center"><a href="https://minaskaramanis.com"><img src="https://avatars2.githubusercontent.com/u/23280751?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Minas Karamanis</b></sub></a><br /><a href="https://github.com/DifferentiableUniverseInitiative/jax_cosmo/commits?author=minaskar" title="Code">πŸ’»</a></td> <td align="center"><a href="https://faculty.sites.uci.edu/dkirkby/"><img src="https://avatars1.githubusercontent.com/u/185007?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David Kirkby</b></sub></a><br /><a href="https://github.com/DifferentiableUniverseInitiative/jax_cosmo/commits?author=dkirkby" title="Code">πŸ’»</a> <a href="https://github.com/DifferentiableUniverseInitiative/jax_cosmo/issues?q=author%3Adkirkby" title="Bug reports">πŸ›</a></td> <td align="center"><a href="https://aboucaud.github.io"><img src="https://avatars0.githubusercontent.com/u/3065310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alexandre Boucaud</b></sub></a><br /><a href="https://github.com/DifferentiableUniverseInitiative/jax_cosmo/commits?author=aboucaud" title="Code">πŸ’»</a></td> <td align="center"><a href="https://www.cosmostat.org/people/denise-lanzieri"><img src="https://avatars.githubusercontent.com/u/72620117?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Denise Lanzieri</b></sub></a><br /><a href="https://github.com/DifferentiableUniverseInitiative/jax_cosmo/commits?author=dlanzieri" title="Code">πŸ’»</a></td> </tr> <tr> <td align="center"><a href="https://github.com/jecampagne"><img src="https://avatars.githubusercontent.com/u/20539759?v=4?s=100" width="100px;" alt=""/><br /><sub><b>jecampagne</b></sub></a><br /><a href="https://github.com/DifferentiableUniverseInitiative/jax_cosmo/issues?q=author%3Ajecampagne" title="Bug reports">πŸ›</a></td> <td align="center"><a href="https://github.com/eelregit"><img src="https://avatars.githubusercontent.com/u/7311098?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yin Li</b></sub></a><br /><a href="https://github.com/DifferentiableUniverseInitiative/jax_cosmo/commits?author=eelregit" title="Code">πŸ’»</a> <a href="https://github.com/DifferentiableUniverseInitiative/jax_cosmo/issues?q=author%3Aeelregit" title="Bug reports">πŸ›</a></td> </tr> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the all-contributors specification. Contributions of any kind welcome!