celnn
celnn is a reusable Python package for CelNN
(Cellular Neural Networks) as locally connected nonlinear
dynamical systems over regular grids, signals, and image-like arrays.
Cellular Neural Networks are not Convolutional Neural Networks.
In this project, CelNN means a continuous-time cellular dynamical
system with local coupling, templates, states, outputs, inputs, and
bias terms.
Installation
pip install celnn
For optional SciPy, image, and plotting support:
pip install celnn[all]
For GPU execution through CuPy/CUDA:
pip install celnn[gpu]
For genetic-algorithm-based template training (powered by DEAP):
pip install celnn[ga]
For differentiable templates and backpropagation through CelNN evolution:
pip install "celnn[torch]"
The same optional API includes modular Hebbian/Oja fast-weight plasticity with explicit per-sequence state. See the plasticity guide.
Use device="gpu" to require GPU execution, device="auto" to try GPU
and fall back to CPU, or device="cpu" for the default NumPy backend.
Development and verification
Create the canonical development environment:
conda env create -f environment.yml
conda activate pycelnn
pip install -e . --no-deps
Run local checks:
python -m compileall src
pytest
ruff check .
mypy src/celnn/core/network.py src/celnn/core/simulation.py src/celnn/core/solvers.py
Quick start
import numpy as np
from celnn import CellularNetwork, SimulationConfig
u = np.random.rand(32, 32)
net = CellularNetwork(
input=u,
feedback=np.array([[0.0, 0.1, 0.0], [0.1, 1.0, 0.1], [0.0, 0.1, 0.0]]),
control=np.array([[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]]),
bias=0.0,
boundary="reflect",
device="auto",
)
result = net.run(SimulationConfig(t_end=1.0, dt=0.01))
print(result.output.shape)
Documentation shortcuts
- CelNN: concept, theory, and study notes
- Library usage and API guide
- Examples
- Mathematical model
- Template design guide
- Template creation guide
- Migration from PyCNN
- Differentiable network and PyTorch usage
Features
- Generic
CellularNetworkAPI for 1D, 2D, and SciPy-backed ND simulations. - Reusable
TemplateandTemplateRegistryabstractions. - Built-in activation functions, boundary modes, and solver options.
- Optional CuPy/CUDA backend for GPU local stencil aggregation.
- Optional image, signal, grid, serialization, and visualization helpers.
- Optional genetic-algorithm-based template trainer (DEAP).
- Optional
DifferentiableCellularNetworkwith learnable PyTorch templates. - Demonstrative built-in templates for image processing, logic, diffusion, and pattern formation.
- Tests, examples, and technical documentation aimed at research and experimentation.
Minimal example
import numpy as np
from celnn import CellularNetwork, SimulationConfig
from celnn.activations import tanh_activation
signal = np.sin(np.linspace(0, 8 * np.pi, 512))
net = CellularNetwork(
input=signal,
feedback=np.array([0.2, 1.0, 0.2]),
control=np.array([0.1, 0.8, 0.1]),
bias=0.0,
activation=tanh_activation,
boundary="reflect",
)
result = net.run(SimulationConfig(t_end=5.0, dt=0.05))
print(result.output[:5])
Implementation status
- Maturity: alpha (
0.1.x), focused on regular-grid CelNN systems. - CI-verified baseline: CPU/NumPy dynamics, SciPy solver path, templates, serialization, and image/signal utilities.
- GPU coverage:
- deterministic CuPy backend behavior is tested in CI with a stubbed CuPy runtime.
- real CUDA execution tests run when CuPy and a CUDA device are available (tests skip otherwise).
License
This repository is distributed under the Apache-2.0 license. See LICENSE.
Attribution
celnn is an original, generalized library design inspired in part by
the MIT-licensed PyCNN
project, which focused on image processing with Cellular Neural
Networks.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file celnn-0.3.2.tar.gz.
File metadata
- Download URL: celnn-0.3.2.tar.gz
- Upload date:
- Size: 70.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d306af6ca1d13af6d03e68459b15e20f3c6e6f829ae8322e0b391ec75e9dafdf
|
|
| MD5 |
1bdeb7e38761fe0faba5b749588a9e39
|
|
| BLAKE2b-256 |
314a8fc2034ef4e7f355357a6a0b93aeaf46e792a9d84d5ede2a93d9480fe887
|
File details
Details for the file celnn-0.3.2-py3-none-any.whl.
File metadata
- Download URL: celnn-0.3.2-py3-none-any.whl
- Upload date:
- Size: 69.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7551efd5beeb8d73fae77e2a6ec2cc7fd306ea3ccdbf62369e71763779219b73
|
|
| MD5 |
b3b8a83a33138778f01e4f2601ff4da4
|
|
| BLAKE2b-256 |
27321b209b3d2b0f9aa9d7016cd405b4610b38003b025471897edaad312e0981
|