cax


Namecax JSON
Version 0.1.5 PyPI version JSON
download
home_pageNone
SummaryCellular Automata Accelerated in JAX
upload_time2024-09-24 15:22:41
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License Copyright (c) 2024 Maxence Faldor Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords cellular automata self-organization emergence
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CAX: Cellular Automata Accelerated
[![Pyversions](https://img.shields.io/pypi/pyversions/cax.svg?style=flat-square)](https://pypi.python.org/pypi/cax) [![PyPI version](https://badge.fury.io/py/cax.svg)](https://badge.fury.io/py/cax)

CAX is a high-performance cellular automata library built on top of JAX/Flax that is **designed for flexiblity**.

## Overview 🔎

CAX is a cutting-edge library designed to implement and accelerate various types of cellular automata using the JAX framework. Whether you're a researcher, a hobbyist, or just curious about the fascinating world of emergent and self-organizing systems, CAX has got you covered! 🧬

Despite their conceptual simplicity, cellular automata often demand significant computational resources. The parallel update of numerous cells, coupled with the need for backpropagation through time in neural cellular automata training, can render these models computationally intensive. CAX leverages hardware accelerators and massive parallelization to run cellular automata experiments in minutes. 🚀

The library works with discrete or continuous cellular automata of any spatial dimension, offering exceptional flexibility. From simulating one-dimensional [elementary cellular automata](https://github.com/maxencefaldor/cax/blob/main/examples/elementary_ca.ipynb) to training three-dimensional [self-autoencoding neural cellular automata](https://github.com/maxencefaldor/cax/blob/main/examples/self_autoencoding_mnist.ipynb), and even creating beautiful [Lenia simulations](https://github.com/maxencefaldor/cax/blob/main/examples/lenia.ipynb), CAX provides a versatile platform for exploring the rich world of self-organizing systems. ✨

## Implemented Cellular Automata 🦎

| Cellular Automata | Reference | Example |
| --- | --- | --- |
| Elementary Cellular Automata | [Wolfram, Stephen (2002)](https://www.wolframscience.com/nks/) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/elementary_ca.ipynb) |
| Conway's Game of Life | [Gardner, Martin (1970)](https://web.stanford.edu/class/sts145/Library/life.pdf) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/life.ipynb) |
| Lenia | [Chan, Bert Wang-Chak (2020)](https://arxiv.org/pdf/2005.03742) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/lenia.ipynb) |
| Growing Neural Cellular Automata | [Mordvintsev, et al. (2020)](https://distill.pub/2020/growing-ca/) |[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/growing_nca.ipynb) |
| Growing Conditional Neural Cellular Automata | Faldor, et al. (2024) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/growing_conditional_nca.ipynb) |
| Growing Unsupervised Neural Cellular Automata | Faldor, et al. (2024) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/growing_unsupervised_nca.ipynb) |
| Self-classifying MNIST Digits | [Randazzo, et al. (2020)](https://distill.pub/2020/selforg/mnist/) |[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/self_classifying_mnist.ipynb) |
| Self-autoencoding MNIST Digits | Faldor, et al. (2024) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/self_autoencoding_mnist.ipynb) |
| Diffusing Neural Cellular Automata | Faldor, et al. (2024) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/diffusing_nca.ipynb) |

## Installation 🛠️

You will need Python 3.10 or later, and a working JAX installation.

Then, install CAX from PyPi:
```
pip install cax
```

To upgrade to the latest version of CAX, you can use:
```
pip install --upgrade git+https://github.com/maxencefaldor/cax.git
```

## Getting Started 🚦

```python
import jax
from cax.core.ca import CA
from cax.core.perceive.depthwise_conv_perceive import DepthwiseConvPerceive
from cax.core.update.nca_update import NCAUpdate
from flax import nnx

seed = 0

channel_size = 16
num_kernels = 3
hidden_size = 128
cell_dropout_rate = 0.5

key = jax.random.key(seed)
rngs = nnx.Rngs(seed)

perceive = DepthwiseConvPerceive(channel_size, rngs)
update = NCAUpdate(
	channel_size,
	num_kernels*channel_size,
	(hidden_size,),
	rngs,
	cell_dropout_rate=cell_dropout_rate
)
ca = CA(perceive, update)

state = jax.random.normal(key, (64, 64, channel_size))
state = ca(state, num_steps=128)
```

## Citing CAX 📝

To cite this repository:

```
@software{cax2024,
	author = {Faldor, Maxence and Cully, Antoine},
	title = {{CAX}: Cellular Automata Accelerated in {JAX}},
	url = {http://github.com/maxencefaldor/cax},
	version = {0.1.5},
	year = {2024},
}
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cax",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "cellular automata, self-organization, emergence",
    "author": null,
    "author_email": "Maxence Faldor <maxencefaldor@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/de/52/d1c35e27150d6e7446bddf7876a4edd83048e796cfa4cb5ba012ee0815f8/cax-0.1.5.tar.gz",
    "platform": null,
    "description": "# CAX: Cellular Automata Accelerated\n[![Pyversions](https://img.shields.io/pypi/pyversions/cax.svg?style=flat-square)](https://pypi.python.org/pypi/cax) [![PyPI version](https://badge.fury.io/py/cax.svg)](https://badge.fury.io/py/cax)\n\nCAX is a high-performance cellular automata library built on top of JAX/Flax that is **designed for flexiblity**.\n\n## Overview \ud83d\udd0e\n\nCAX is a cutting-edge library designed to implement and accelerate various types of cellular automata using the JAX framework. Whether you're a researcher, a hobbyist, or just curious about the fascinating world of emergent and self-organizing systems, CAX has got you covered! \ud83e\uddec\n\nDespite their conceptual simplicity, cellular automata often demand significant computational resources. The parallel update of numerous cells, coupled with the need for backpropagation through time in neural cellular automata training, can render these models computationally intensive. CAX leverages hardware accelerators and massive parallelization to run cellular automata experiments in minutes. \ud83d\ude80\n\nThe library works with discrete or continuous cellular automata of any spatial dimension, offering exceptional flexibility. From simulating one-dimensional [elementary cellular automata](https://github.com/maxencefaldor/cax/blob/main/examples/elementary_ca.ipynb) to training three-dimensional [self-autoencoding neural cellular automata](https://github.com/maxencefaldor/cax/blob/main/examples/self_autoencoding_mnist.ipynb), and even creating beautiful [Lenia simulations](https://github.com/maxencefaldor/cax/blob/main/examples/lenia.ipynb), CAX provides a versatile platform for exploring the rich world of self-organizing systems. \u2728\n\n## Implemented Cellular Automata \ud83e\udd8e\n\n| Cellular Automata | Reference | Example |\n| --- | --- | --- |\n| Elementary Cellular Automata | [Wolfram, Stephen (2002)](https://www.wolframscience.com/nks/) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/elementary_ca.ipynb) |\n| Conway's Game of Life | [Gardner, Martin (1970)](https://web.stanford.edu/class/sts145/Library/life.pdf) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/life.ipynb) |\n| Lenia | [Chan, Bert Wang-Chak (2020)](https://arxiv.org/pdf/2005.03742) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/lenia.ipynb) |\n| Growing Neural Cellular Automata | [Mordvintsev, et al. (2020)](https://distill.pub/2020/growing-ca/) |[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/growing_nca.ipynb) |\n| Growing Conditional Neural Cellular Automata | Faldor, et al. (2024) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/growing_conditional_nca.ipynb) |\n| Growing Unsupervised Neural Cellular Automata | Faldor, et al. (2024) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/growing_unsupervised_nca.ipynb) |\n| Self-classifying MNIST Digits | [Randazzo, et al. (2020)](https://distill.pub/2020/selforg/mnist/) |[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/self_classifying_mnist.ipynb) |\n| Self-autoencoding MNIST Digits | Faldor, et al. (2024) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/self_autoencoding_mnist.ipynb) |\n| Diffusing Neural Cellular Automata | Faldor, et al. (2024) | [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/diffusing_nca.ipynb) |\n\n## Installation \ud83d\udee0\ufe0f\n\nYou will need Python 3.10 or later, and a working JAX installation.\n\nThen, install CAX from PyPi:\n```\npip install cax\n```\n\nTo upgrade to the latest version of CAX, you can use:\n```\npip install --upgrade git+https://github.com/maxencefaldor/cax.git\n```\n\n## Getting Started \ud83d\udea6\n\n```python\nimport jax\nfrom cax.core.ca import CA\nfrom cax.core.perceive.depthwise_conv_perceive import DepthwiseConvPerceive\nfrom cax.core.update.nca_update import NCAUpdate\nfrom flax import nnx\n\nseed = 0\n\nchannel_size = 16\nnum_kernels = 3\nhidden_size = 128\ncell_dropout_rate = 0.5\n\nkey = jax.random.key(seed)\nrngs = nnx.Rngs(seed)\n\nperceive = DepthwiseConvPerceive(channel_size, rngs)\nupdate = NCAUpdate(\n\tchannel_size,\n\tnum_kernels*channel_size,\n\t(hidden_size,),\n\trngs,\n\tcell_dropout_rate=cell_dropout_rate\n)\nca = CA(perceive, update)\n\nstate = jax.random.normal(key, (64, 64, channel_size))\nstate = ca(state, num_steps=128)\n```\n\n## Citing CAX \ud83d\udcdd\n\nTo cite this repository:\n\n```\n@software{cax2024,\n\tauthor = {Faldor, Maxence and Cully, Antoine},\n\ttitle = {{CAX}: Cellular Automata Accelerated in {JAX}},\n\turl = {http://github.com/maxencefaldor/cax},\n\tversion = {0.1.5},\n\tyear = {2024},\n}\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Maxence Faldor  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Cellular Automata Accelerated in JAX",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/maxencefaldor/cax"
    },
    "split_keywords": [
        "cellular automata",
        " self-organization",
        " emergence"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f6e9d5f75a2cfb05d66e4df41f5b391c6f7d7a1f2026b3d399b2ce1beefb0bdb",
                "md5": "21741d9f47b2bf78eb82f5a281904b8a",
                "sha256": "73c5342b9d0252d4bda096023d61a837b2dd3f856c58f7f963fb62f3d7e4aa55"
            },
            "downloads": -1,
            "filename": "cax-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "21741d9f47b2bf78eb82f5a281904b8a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 23468,
            "upload_time": "2024-09-24T15:22:39",
            "upload_time_iso_8601": "2024-09-24T15:22:39.972572Z",
            "url": "https://files.pythonhosted.org/packages/f6/e9/d5f75a2cfb05d66e4df41f5b391c6f7d7a1f2026b3d399b2ce1beefb0bdb/cax-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "de52d1c35e27150d6e7446bddf7876a4edd83048e796cfa4cb5ba012ee0815f8",
                "md5": "c8bd8e8cafdb7440ef78b478af323104",
                "sha256": "0fb512c446474964c9bfe78860557167077debdf5579d60f0ecad99767ef98c8"
            },
            "downloads": -1,
            "filename": "cax-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "c8bd8e8cafdb7440ef78b478af323104",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 17978,
            "upload_time": "2024-09-24T15:22:41",
            "upload_time_iso_8601": "2024-09-24T15:22:41.459631Z",
            "url": "https://files.pythonhosted.org/packages/de/52/d1c35e27150d6e7446bddf7876a4edd83048e796cfa4cb5ba012ee0815f8/cax-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-24 15:22:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "maxencefaldor",
    "github_project": "cax",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cax"
}
        
Elapsed time: 0.98109s