cax 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cax/__init__.py +3 -0
- cax/types.py +8 -0
- cax-0.1.0.dist-info/LICENSE +21 -0
- cax-0.1.0.dist-info/METADATA +150 -0
- cax-0.1.0.dist-info/RECORD +7 -0
- cax-0.1.0.dist-info/WHEEL +5 -0
- cax-0.1.0.dist-info/top_level.txt +1 -0
cax/__init__.py
ADDED
cax/types.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Maxence Faldor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: cax
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Cellular Automata Accelerated in JAX
|
|
5
|
+
Author-email: Maxence Faldor <maxencefaldor@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024 Maxence Faldor
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/maxencefaldor/cax
|
|
29
|
+
Project-URL: Issues, https://github.com/maxencefaldor/cax/issues
|
|
30
|
+
Keywords: cellular automata,self-organization,emergence
|
|
31
|
+
Classifier: Programming Language :: Python :: 3
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Operating System :: OS Independent
|
|
34
|
+
Requires-Python: >=3.11
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
License-File: LICENSE
|
|
37
|
+
Requires-Dist: numpy >=2.1.0
|
|
38
|
+
Requires-Dist: jax >=0.4.31
|
|
39
|
+
Requires-Dist: flax >=0.9.0
|
|
40
|
+
Requires-Dist: optax >=0.2.3
|
|
41
|
+
Requires-Dist: datasets >=2.21.0
|
|
42
|
+
Requires-Dist: pillow >=10.4.0
|
|
43
|
+
Requires-Dist: ipython >=8.26.0
|
|
44
|
+
Requires-Dist: ipykernel >=6.29.5
|
|
45
|
+
Requires-Dist: ipywidgets >=8.1.5
|
|
46
|
+
Requires-Dist: mediapy >=1.2.2
|
|
47
|
+
Provides-Extra: cuda
|
|
48
|
+
Requires-Dist: jax[cuda12] ; extra == 'cuda'
|
|
49
|
+
Provides-Extra: dev
|
|
50
|
+
Requires-Dist: pytest >=8.3.2 ; extra == 'dev'
|
|
51
|
+
Requires-Dist: pytest-cov >=5.0.0 ; extra == 'dev'
|
|
52
|
+
Requires-Dist: ruff >=0.6.4 ; extra == 'dev'
|
|
53
|
+
Requires-Dist: mypy >=1.11.2 ; extra == 'dev'
|
|
54
|
+
Requires-Dist: pre-commit ; extra == 'dev'
|
|
55
|
+
Provides-Extra: tpu
|
|
56
|
+
Requires-Dist: jax[tpu] ; extra == 'tpu'
|
|
57
|
+
|
|
58
|
+
# CAX: Cellular Automata Accelerated
|
|
59
|
+
|
|
60
|
+
CAX is a high-performance cellular automata library built on top of JAX/Flax that is **designed for flexiblity**.
|
|
61
|
+
|
|
62
|
+
## Overview 🔎
|
|
63
|
+
|
|
64
|
+
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! 🧬
|
|
65
|
+
|
|
66
|
+
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. 🚀
|
|
67
|
+
|
|
68
|
+
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. ✨
|
|
69
|
+
|
|
70
|
+
## Implemented Cellular Automata 🦎
|
|
71
|
+
|
|
72
|
+
| Cellular Automata | Reference | Example |
|
|
73
|
+
| --- | --- | --- |
|
|
74
|
+
| Elementary Cellular Automata | [Wolfram, Stephen (2002)](https://www.wolframscience.com/nks/) | [](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/elementary_ca.ipynb) |
|
|
75
|
+
| Conway's Game of Life | [Gardner, Martin (1970)](https://web.stanford.edu/class/sts145/Library/life.pdf) | [](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/life.ipynb) |
|
|
76
|
+
| Lenia | [Chan, Bert Wang-Chak (2020)](https://arxiv.org/pdf/2005.03742) | [](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/lenia.ipynb) |
|
|
77
|
+
| Growing Neural Cellular Automata | [Mordvintsev, et al. (2020)](https://distill.pub/2020/growing-ca/) |[](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/growing_nca.ipynb) |
|
|
78
|
+
| Growing Conditional Neural Cellular Automata | Faldor, et al. (2024) | [](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/growing_conditional_nca.ipynb) |
|
|
79
|
+
| Growing Unsupervised Neural Cellular Automata | Faldor, et al. (2024) | [](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/growing_unsupervised_nca.ipynb) |
|
|
80
|
+
| Self-classifying MNIST Digits | [Randazzo, et al. (2020)](https://distill.pub/2020/selforg/mnist/) |[](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/self_classifying_mnist.ipynb) |
|
|
81
|
+
| Self-autoencoding MNIST Digits | Faldor, et al. (2024) | [](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/self_autoencoding_mnist.ipynb) |
|
|
82
|
+
| Diffusing Neural Cellular Automata | Faldor, et al. (2024) | [](https://colab.research.google.com/github/maxencefaldor/cax/blob/main/examples/diffusing_nca.ipynb) |
|
|
83
|
+
|
|
84
|
+
## Installation 🛠️
|
|
85
|
+
|
|
86
|
+
You will need Python 3.12 or later. Then, install CAX from PyPi:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
pip install cax
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
To upgrade to the latest version of CAX, you can use:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
pip install --upgrade git+https://github.com/maxencefaldor/cax.git
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
By default, CAX is installed on CPU, but you can install it on GPU or TPU with:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
pip install jax[cuda12]
|
|
102
|
+
pip install jax[tpu]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Getting Started 🚦
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
import jax
|
|
109
|
+
from cax.core.ca import CA
|
|
110
|
+
from cax.core.perceive.dwconv_perceive import DWConvPerceive
|
|
111
|
+
from cax.core.update.nca_update import NCAUpdate
|
|
112
|
+
from flax import nnx
|
|
113
|
+
|
|
114
|
+
seed = 0
|
|
115
|
+
|
|
116
|
+
channel_size = 16
|
|
117
|
+
num_kernels = 3
|
|
118
|
+
hidden_size = 128
|
|
119
|
+
cell_dropout_rate = 0.5
|
|
120
|
+
|
|
121
|
+
key = jax.random.PRNGKey(seed)
|
|
122
|
+
rngs = nnx.Rngs(seed)
|
|
123
|
+
|
|
124
|
+
perceive = DWConvPerceive(channel_size, rngs)
|
|
125
|
+
update = NCAUpdate(
|
|
126
|
+
channel_size,
|
|
127
|
+
num_kernels*channel_size,
|
|
128
|
+
(hidden_size,),
|
|
129
|
+
rngs,
|
|
130
|
+
cell_dropout_rate=cell_dropout_rate
|
|
131
|
+
)
|
|
132
|
+
ca = CA(perceive, update)
|
|
133
|
+
|
|
134
|
+
state = jax.random.normal(key, (64, 64, channel_size))
|
|
135
|
+
state = ca(state, num_steps=128)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Citing CAX 📝
|
|
139
|
+
|
|
140
|
+
To cite this repository:
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
@software{cax2024,
|
|
144
|
+
author = {Faldor, Maxence and Cully, Antoine},
|
|
145
|
+
title = {{CAX}: Cellular Automata Accelerated in {JAX}},
|
|
146
|
+
url = {http://github.com/maxencefaldor/cax},
|
|
147
|
+
version = {0.1.0},
|
|
148
|
+
year = {2024},
|
|
149
|
+
}
|
|
150
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
cax/__init__.py,sha256=78oS_ZXi1sj96Z-fQi6rEbHA4jF5hhAUCY6OyGqLLKU,65
|
|
2
|
+
cax/types.py,sha256=eb8oygtcXlodv1oRMI5_fGnnCD-4vtw15JSsPdWdqYk,173
|
|
3
|
+
cax-0.1.0.dist-info/LICENSE,sha256=nob3TF0OW6oqAk7ZG18mhAlA2piyUlFkT3aOn6ocQYI,1071
|
|
4
|
+
cax-0.1.0.dist-info/METADATA,sha256=mFl7CzE81ler1qeLMlG60xuvL2ueewkGv45EBJuQapM,7698
|
|
5
|
+
cax-0.1.0.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
|
6
|
+
cax-0.1.0.dist-info/top_level.txt,sha256=8dtXNnbZgfwlA1NgLAWV8zkTc52pMWV9qPoXol8Wxco,4
|
|
7
|
+
cax-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cax
|