SARN - Self-Adaptive Rewiring Neural Network
Project description
SARN: Self-Adaptive Rewiring Neural Network
SARN is a modular, brain-inspired neural network engine that supports sparse top-k activations, neurogenesis, self-rewiring, and biological activation functions. Designed to simulate real neuron behavior, it's ideal for building your own evolving neural systems with full control over nodes, weights, connections, and more.
🌟 Features
- SARN Layers — Top-k activated sparse neurons with rewiring
- Neuron Growth — Dynamically adds neurons when novelty is detected
- Hebbian Plasticity — Rewires weights based on usage strength
- Fully Modular — Build networks with any size, connection config, and activation
Getting Started
🔧 Install via PyPI
pip install sarn-ai
$ Clone this repository
git clone https://github.com/yourusername/sarn-ai.git
cd sarn-ai
pip install -e .
☁ Usage
Example
from SarnAi import SARNLayer, SARNNetwork
# Define a custom SARN-based network
input_layer = SARNLayer(input_size=4, output_size=8, k=3)
hidden_layer = SARNLayer(input_size=8, output_size=6, k=2)
output_layer = SARNLayer(input_size=6, output_size=2, k=1)
model = SARNNetwork([input_layer, hidden_layer, output_layer])
# Forward pass
output = model.forward([0.3, 0.7, 0.1, 0.9])
print("Output:", output)
# Self-adapt via rewiring and neuron growth
model.adapt()
Activation Functions
from SarnAi.functions import neuro_spike, adaptive_pulse, neuro_softmax
| Function | Uses |
|---|---|
neuro_spike |
Peak around x=1 like a firing neuron |
adaptive_pulse |
Smooth pulse that adapts with input |
neuro_softmax |
Confidence-weighted class activation |
⚙️ API Overeview
Class
| Class | Description |
|---|---|
SARNLayer |
Customizable sparse neural layer with weights and top-k fire |
SARNNetwork |
Connect multiple layers and manage memory + neurogenesis |
Functions
| Function | Purpose |
|---|---|
model.forward(input) |
Runs input through all SARN layers |
model.adapt() |
Rewires weights and grows neurons if needed |
layer.set_weights() |
Manually set layer weights |
layer.add_neuron() |
Dynamically add a neuron to a layer |
Contributing
Pull requests are welcome! If you want to propose improvements or report issues, feel free to fork the repo and open a PR or GitHub Issue.
!Note: This project is in active development and experimental.
📈 Star History
Project details
Release history Release notifications | RSS feed
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 sarn-0.1.1.tar.gz.
File metadata
- Download URL: sarn-0.1.1.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1cfa35975861835848563ddb86d5210dd24b09e2bb63c744e5ca74a029a22f9
|
|
| MD5 |
f5cfdd32ed6b033beec757011bbe3f1d
|
|
| BLAKE2b-256 |
6036600bcd40f5b3c0b855edb3cf8b51c6a109171ad0ad90805597413484c88d
|
File details
Details for the file sarn-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sarn-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38f83e4e8e6984202cb520f678f8a77116356ece36cd729bbe1ff4cf3f5a0bb0
|
|
| MD5 |
171d4791421da3011ce05d58cce8897d
|
|
| BLAKE2b-256 |
a583e385dac6b0dc70196785f383e6affdb4bb0efa4c4851cbbb5a87e1f7a6a7
|