{"id":16599939,"url":"https://github.com/dirmeier/surjectors","last_synced_at":"2025-10-29T13:30:59.282Z","repository":{"id":184470132,"uuid":"550384046","full_name":"dirmeier/surjectors","owner":"dirmeier","description":"Surjection layers for density estimation with normalizing flows","archived":false,"fork":false,"pushed_at":"2025-08-29T13:02:37.000Z","size":489,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-26T00:55:18.884Z","etag":null,"topics":["bijections","density-estimation","normalizing-flows","python","surjections"],"latest_commit_sha":null,"homepage":"https://surjectors.rtfd.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dirmeier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-10-12T17:10:51.000Z","updated_at":"2025-08-21T19:44:29.000Z","dependencies_parsed_at":"2024-08-17T21:43:43.159Z","dependency_job_id":"5ec52b06-5419-40e9-bde5-8fbe0afb5760","html_url":"https://github.com/dirmeier/surjectors","commit_stats":null,"previous_names":["dirmeier/surjectors"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/dirmeier/surjectors","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fsurjectors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fsurjectors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fsurjectors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fsurjectors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dirmeier","download_url":"https://codeload.github.com/dirmeier/surjectors/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirmeier%2Fsurjectors/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281544195,"owners_count":26519554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-29T02:00:06.901Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bijections","density-estimation","normalizing-flows","python","surjections"],"created_at":"2024-10-12T00:13:03.028Z","updated_at":"2025-10-29T13:30:58.928Z","avatar_url":"https://github.com/dirmeier.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# surjectors\n\n[![active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![ci](https://github.com/dirmeier/surjectors/actions/workflows/ci.yaml/badge.svg)](https://github.com/dirmeier/surjectors/actions/workflows/ci.yaml)\n[![version](https://img.shields.io/pypi/v/surjectors.svg?colorB=black\u0026style=flat)](https://pypi.org/project/surjectors/)\n[![doi](https://joss.theoj.org/papers/10.21105/joss.06188/status.svg)](https://doi.org/10.21105/joss.06188)\n\n\u003e Surjection layers for density estimation with normalizing flows\n\n## About\n\nSurjectors is a light-weight library for density estimation using\ninference and generative surjective normalizing flows, i.e., flows can that reduce or increase dimensionality.\nSurjectors makes use of\n\n- [Haiku](https://github.com/deepmind/dm-haiku)`s module system for neural networks,\n- [Distrax](https://github.com/deepmind/distrax) for probability distributions and some base bijectors,\n- [Optax](https://github.com/deepmind/optax) for gradient-based optimization,\n- [JAX](https://github.com/google/jax) for autodiff and XLA computation.\n\n## Examples\n\nYou can, for instance, construct a simple normalizing flow like this:\n\n```python\nimport distrax\nimport haiku as hk\nfrom jax import numpy as jnp, random as jr\nfrom surjectors import Slice, LULinear, Chain\nfrom surjectors import TransformedDistribution\nfrom surjectors.nn import make_mlp\n\ndef decoder_fn(n_dim):\n    def _fn(z):\n        params = make_mlp([32, 32, n_dim * 2])(z)\n        means, log_scales = jnp.split(params, 2, -1)\n        return distrax.Independent(distrax.Normal(means, jnp.exp(log_scales)))\n    return _fn\n\n@hk.without_apply_rng\n@hk.transform\ndef flow(x):\n    base_distribution = distrax.Independent(\n        distrax.Normal(jnp.zeros(5), jnp.ones(5)), 1\n    )\n    transform = Chain([Slice(5, decoder_fn(5)), LULinear(5)])\n    pushforward = TransformedDistribution(base_distribution, transform)\n    return pushforward.log_prob(x)\n\nx = jr.normal(jr.PRNGKey(1), (1, 10))\nparams = flow.init(jr.PRNGKey(2), x)\nlp = flow.apply(params, x)\n```\n\nMore self-contained examples can be found in [examples](https://github.com/dirmeier/surjectors/tree/main/examples).\n\n## Documentation\n\nDocumentation can be found [here](https://surjectors.readthedocs.io/en/latest/).\n\n## Installation\n\nMake sure to have a working `JAX` installation. Depending whether you want to use CPU/GPU/TPU,\nplease follow [these instructions](https://github.com/google/jax#installation).\n\nTo install the package from PyPI, call:\n\n```bash\npip install surjectors\n```\n\nTo install the latest GitHub \u003cRELEASE\u003e, just call the following on the command line:\n\n```bash\npip install git+https://github.com/dirmeier/surjectors@\u003cRELEASE\u003e\n```\n\n## Contributing\n\nContributions in the form of pull requests are more than welcome. A good way to start is to check out issues labelled\n[good first issue](https://github.com/dirmeier/surjectors/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).\n\nIn order to contribute:\n\n1) Clone `Surjectors` and install `hatch` via `pip install hatch`,\n2) create a new branch locally `git checkout -b feature/my-new-feature` or `git checkout -b issue/fixes-bug`,\n3) implement your contribution and ideally a test case,\n4) test it by calling `hatch run test` on the (Unix) command line,\n5) submit a PR 🙂\n\n\n## Citing Surjectors\n\nIf you find our work relevant to your research, please consider citing:\n\n```\n@article{dirmeier2024surjectors,\n    author = {Simon Dirmeier},\n    title = {Surjectors: surjection layers for density estimation with normalizing flows},\n    year = {2024},\n    journal = {Journal of Open Source Software},\n    publisher = {The Open Journal},\n    volume = {9},\n    number = {94},\n    pages = {6188},\n    doi = {10.21105/joss.06188}\n}\n```\n\n## Author\n\nSimon Dirmeier \u003ca href=\"mailto:sfyrbnd @ pm me\"\u003esfyrbnd @ pm me\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirmeier%2Fsurjectors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirmeier%2Fsurjectors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirmeier%2Fsurjectors/lists"}