-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add docs * setuptools * readme
- Loading branch information
Showing
7 changed files
with
210 additions
and
8 deletions.
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,48 @@ | ||
# distreqx | ||
|
||
Distrax + equinox | ||
distreqx (pronounced "dist-rex") is a [JAX](https://github.com/google/jax)-based library providing implementations of distributions, bijectors, and tools for statistical and probabilistic machine learning with all benefits of jax (native GPU/TPU acceleration, differentiability, vectorization, distributing workloads, XLA compilation, etc.). | ||
|
||
The origin of this package is a reimplementation of [distrax](https://github.com/google-deepmind/distrax), (which is a subset of [TensorFlow Probability (TFP)](https://github.com/tensorflow/probability), with some new features and emphasis on jax compatibility) using [equinox](https://github.com/patrick-kidger/equinox). As a result, much of the original code/comments/documentation/tests are directly taken or adapted from distrax (original distrax copyright available at end of README.) | ||
|
||
Current features include: | ||
|
||
- Probability distributions | ||
- Bijectors | ||
|
||
|
||
## Installation | ||
|
||
``` | ||
git clone https://github.com/lockwo/distreqx.git | ||
cd distreqx | ||
pip install -e . | ||
``` | ||
|
||
Requires Python 3.9+, JAX 0.4.11+, and [Equinox](https://github.com/patrick-kidger/equinox) 0.11.0+. | ||
|
||
## Documentation | ||
|
||
Available at https://lockwo.github.io/distreqx/. | ||
|
||
## Quick example | ||
|
||
```python | ||
from distreqx import distributions | ||
|
||
key = jax.random.PRNGKey(1234) | ||
mu = jnp.array([-1., 0., 1.]) | ||
sigma = jnp.array([0.1, 0.2, 0.3]) | ||
|
||
dist = distributions.MultivariateNormalDiag(mu, sigma) | ||
|
||
samples = dist_distrax.sample(key) | ||
|
||
print(dist_distrax.log_prob(samples)) | ||
``` | ||
|
||
## Differences with Distrax | ||
|
||
- No official support/interoperability with TFP | ||
- The concept of a batch dimension is dropped. If you want to operate on a batch, use `vmap` (note, this can be used in construction as well, e.g. [vmaping the construction](https://docs.kidger.site/equinox/tricks/#ensembling) of a `ScalarAffine`) | ||
- Broader pytree enablement | ||
- Strict [abstract/final](https://docs.kidger.site/equinox/pattern/) design pattern |
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 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 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 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 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