Skip to content

Commit 290fa93

Browse files
committed
Spatial hebb
1 parent 1625600 commit 290fa93

12 files changed

Lines changed: 407 additions & 351 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to OdyssNet will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

7+
## [2.5.0] — 2026-04-30
8+
9+
### Added
10+
- **Spatial Hebbian Plasticity**: Introduced a co-activation learning mechanism (classic Hebbian) alongside the existing STDP-style learning.
11+
- **`hebb_mode` functionality (`hebb_type`)**: `hebb_type` is now repurposed to act as the mechanism toggle: `None` (disabled), `"temporal"`, `"spatial"`, or `"both"`.
12+
- **`hebb_res`**: Controls the structural resolution (`"global"`, `"neuron"`, `"synapse"`). Defaults to `"neuron"`.
13+
14+
### Changed
15+
- **BREAKING**: Replaced single-path Hebbian parameters with path-specific prefixes (`t_hebb_factor` and `s_hebb_factor`, etc.). Existing checkpoints utilizing `hebb_factor` will need to be loaded with `strict=False` and re-trained, or manually patched, as we have prioritized a clean architecture over legacy support.
16+
717
## [2.4.0] — 2026-04-10
818

919
### Added

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors:
55
given-names: "Cahit"
66
email: "cksoftwaresystems@gmail.com"
77
title: "OdyssNet: The Trainable Dynamic System & Zero-Hidden Architecture"
8-
version: 2.4.0
8+
version: 2.5.0
99
date-released: 2025-12-12
1010
url: "https://github.com/theomgdev/OdyssNet"
1111
abstract: "OdyssNet is a chaotic, fully connected neural network architecture that proves temporal depth (thinking steps) can replace spatial depth (hidden layers). It solves non-linear problems like MNIST with Zero Hidden Layers by utilizing Trainable Chaos."

CONTRIBUTING.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,17 @@ For tasks requiring high input/output dimensionality (like vision or LLMs) witho
155155
model = OdyssNet(num_neurons=10, ..., vocab_size=(784, 10))
156156
```
157157

158-
### F. Heterogeneous Synaptic Plasticity (`hebb_type`)
159-
For tasks where **online synaptic plasticity** may help — e.g., fast-adaptation, continual learning, or tasks with shifting statistics — enable one of the three resolution levels:
158+
### F. Heterogeneous Synaptic Plasticity (`hebb_type` & `hebb_res`)
159+
For tasks where **online synaptic plasticity** may help — e.g., fast-adaptation, continual learning, or tasks with shifting statistics — enable `hebb_type` (`"temporal"`, `"spatial"`, or `"both"`) and choose one of the three resolution levels:
160160

161-
| `hebb_type` | Extra Params | When to use |
161+
| `hebb_res` | Extra Params per path | When to use |
162162
|---|---|---|
163163
| `"global"` | +2 | Quick experiments; uniform plasticity across all synapses. |
164164
| `"neuron"` | +2N | RL and reactive environments; per-neuron "caste" differentiation. |
165165
| `"synapse"` | +2N² | Logic, NLP, and reasoning tasks requiring **dynamic variable binding**. |
166166

167-
* **What it does:** At each step the network accumulates temporal cross-neuron correlations $C_t = h_t \otimes h_{t-1}$ and applies them as $W_\text{eff} = W + (f_h \odot C_t)$ (where $f_h$ is `hebb_factor`). Both `hebb_factor` and `hebb_decay` are **learnable** — the network discovers how plastic each synapse should be.
168-
* **State:** Correlations are persisted via buffers (`hebb_state_W`, `hebb_state_mem`) across intra-sequence forward calls and are explicitly cleared on `reset_state()` between sequences.
167+
* **What it does:** At each step the network accumulates correlations (temporal $C_t = h_t \otimes h_{t-1}$ and/or spatial $C_s = h_t \otimes h_t$) depending on `hebb_type`. It applies them to the weights. Both factors and decays (`t_hebb_factor`, `s_hebb_factor`, etc.) are **learnable** — the network discovers how plastic each synapse should be.
168+
* **State:** Correlations are persisted via buffers (`t_hebb_state_W`, `s_hebb_state_mem`, etc.) across intra-sequence forward calls and are explicitly cleared on `reset_state()` between sequences.
169169
* **Best Use Case (Generation / Sequential Building):** Hebbian shines in tasks where step T relies heavily on expanding or completing a pattern from step T-1. It provides a powerful **short-term working memory** between steps, acting as a dynamic shortcut that fast-tracks sequence generation.
170170
* **When *not* to use it (Classification / Independent Features):** Avoid Hebbian in classification tasks where each step processes distinct, independent chunks of information (e.g. sequential MNIST classification). In these tasks, inter-step short-term memory acts as "overfit noise".
171171
* **Compatibility:** Fully compatible with `gradient_checkpointing=True`.
@@ -178,7 +178,8 @@ model = OdyssNet(
178178
input_ids=[0, 1],
179179
output_ids=[31],
180180
activation='tanh',
181-
hebb_type='synapse', # Per-synapse plasticity
181+
hebb_type='both',
182+
hebb_res='synapse', # Per-synapse plasticity
182183
device='cuda',
183184
)
184185

@@ -188,12 +189,13 @@ model = OdyssNet(
188189
input_ids=list(range(8)),
189190
output_ids=list(range(56, 64)),
190191
activation='tanh',
191-
hebb_type='neuron', # Per-neuron plasticity
192+
hebb_type='temporal',
193+
hebb_res='neuron', # Per-neuron plasticity
192194
device='cuda',
193195
)
194196

195197
# Quick experiment — global plasticity
196-
model = OdyssNet(..., hebb_type='global')
198+
model = OdyssNet(..., hebb_type='spatial', hebb_res='global')
197199

198200
# Default: Prodigy optimizer — auto-calibrates LR, no tuning needed
199201
trainer = OdyssNetTrainer(model)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ OdyssNet achieves its efficiency through **Space-Time Trade-off**. Instead of ad
3535
* **Space-Time Conversion:** Replaces millions of parameters with a few "Thinking Steps".
3636
* **Layerless Architecture:** A single $N \times N$ matrix. No hidden layers.
3737
* **Trainable Chaos:** Uses **StepNorm** and **Tanh** to tame chaotic signals.
38-
* **Heterogeneous Synaptic Plasticity:** Optional online Hebbian learning (`hebb_type='synapse'|'neuron'|'global'`) — the network accumulates temporal neuron correlations and learns *how fast to learn* at global, per-neuron, or per-synapse resolution via fully differentiable logit parameters (`hebb_factor`, `hebb_decay`).
38+
* **Heterogeneous Synaptic Plasticity:** Optional online Hebbian learning (`hebb_type='temporal'|'spatial'|'both'`, `hebb_res='synapse'|'neuron'|'global'`) — the network accumulates correlations and learns *how fast to learn* via fully differentiable logit parameters (`t_hebb_factor`, `s_hebb_decay`, etc.).
3939
* **Skill Transfer via Transplantation:** Learned temporal skills can be transplanted across model sizes and re-used in new tasks.
4040
* **Living Dynamics:** Demonstrates **Willpower** (Latch), **Rhythm** (Stopwatch), and **Resonance** (Sine Wave).
4141

@@ -158,7 +158,7 @@ Uncontrolled feedback loops lead to explosion. OdyssNet engineers the chaos to f
158158
* **StepNorm** acts as gravity, keeping energy bounded.
159159
* **Tanh** filters meaningful signals while maintaining signal symmetry.
160160
* **Prodigy Optimizer (default)**: Auto-calibrates the learning rate continuously — no manual tuning required. Pass an explicit `lr` to use AdamW instead.
161-
* **Heterogeneous Synaptic Plasticity**: When `hebb_type` is set, temporal correlations $h_t \otimes h_{t-1}$ are accumulated each step and injected as $W_\text{eff} = W + (f_h \odot C_t)$ — where `hebb_factor` can be a global scalar, a per-neuron vector, or a full per-synapse matrix. All variants are learnable, letting the network discover how plastic each pathway should be.
161+
* **Heterogeneous Synaptic Plasticity**: When `hebb_type` is set, correlations (temporal $h_t \otimes h_{t-1}$ or spatial $h_t \otimes h_t$) are accumulated each step and injected — where factors like `t_hebb_factor` can be a global scalar, a per-neuron vector, or a full per-synapse matrix. All variants are learnable, letting the network discover how plastic each pathway should be.
162162
* **The Latch Experiment** proved OdyssNet can create a stable attractor to hold a decision forever against noise.
163163

164164
### 5. Why Not RNN or LSTM?

README_TR.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ OdyssNet verimliliğini **Uzay-Zaman Takası** (Space-Time Trade-off) ile sağla
3636
* **Uzay-Zaman Dönüşümü:** Milyonlarca parametrenin yerini birkaç "Düşünme Adımı" alıyor.
3737
* **Katmansız Mimari:** Tek bir $N \times N$ matris. Gizli katman yok.
3838
* **Eğitilebilir Kaos:** Kaotik sinyalleri dizginlemek için **StepNorm** ve **Tanh** kullanır.
39-
* **Heterojen Sinaptik Plastisitesi:** İsteğe bağlı çevrimiçi Hebbian öğrenmesi (`hebb_type='synapse'|'neuron'|'global'`) — ağ zamansal nöron korelasyonlarını biriktirir ve global, nöron başına veya sinaps başına çözünürlükte tamamen türevlenebilir logit parametreleri (`hebb_factor`, `hebb_decay`) aracılığıyla *ne kadar hızlı öğreneceğini* öğrenir.
39+
* **Heterojen Sinaptik Plastisitesi:** İsteğe bağlı çevrimiçi Hebbian öğrenmesi (`hebb_type='temporal'|'spatial'|'both'`, `hebb_res='synapse'|'neuron'|'global'`) — ağ korelasyonları biriktirir ve global, nöron başına veya sinaps başına çözünürlükte tamamen türevlenebilir logit parametreleri (`t_hebb_factor`, `s_hebb_decay`, vb.) aracılığıyla *ne kadar hızlı öğreneceğini* öğrenir.
4040
* **Transplant ile Beceri Transferi:** Öğrenilmiş zamansal beceriler model boyutları arasında taşınabilir ve yeni görevlerde yeniden kullanılabilir.
4141
* **Canlı Dinamikler:** **İrade** (Mandal), **Ritim** (Kronometre) ve **Rezonans** (Sinüs Dalgası) gösterir.
4242

@@ -159,7 +159,7 @@ Kontrolsüz geri besleme döngüleri patlamaya yol açar. OdyssNet kaosun mühen
159159
* **StepNorm** yerçekimi gibi davranır, enerjiyi sınırlı tutar.
160160
* **Tanh** anlamlı sinyalleri filtreler ve sinyal simetrisini korur.
161161
* **Prodigy Optimizer (varsayılan):** Öğrenme hızını sürekli olarak otomatik kalibre eder — manuel ayar gerekmez. Açık bir `lr` değeri geçildiğinde AdamW kullanılır.
162-
* **Heterojen Sinaptik Plastisitesi:** `hebb_type` ayarlandığında her adımda zamansal korelasyonlar $h_t \otimes h_{t-1}$ biriktirilir ve $W_\text{eff} = W + (f_h \odot C_t)$ olarak enjekte edilir — `hebb_factor` global bir skaler, nöron başına vektör veya tam sinaps başına matris olabilir. Tüm çeşitler öğrenilebilir olduğundan ağ, her sinaptik yolun ne kadar plastik olması gerektiğini keşfeder.
162+
* **Heterojen Sinaptik Plastisitesi:** `hebb_type` ayarlandığında her adımda korelasyonlar (zamansal $h_t \otimes h_{t-1}$ veya uzamsal $h_t \otimes h_t$) biriktirilir ve enjekte edilir — `t_hebb_factor` gibi faktörler global bir skaler, nöron başına vektör veya tam sinaps başına matris olabilir. Tüm çeşitler öğrenilebilir olduğundan ağ, her sinaptik yolun ne kadar plastik olması gerektiğini keşfeder.
163163
* **Mandal Deneyi** OdyssNet'in gürültüye karşı bir kararı sonsuza kadar tutmak için kararlı bir çekici oluşturabileceğini kanıtladı.
164164

165165
### 5. Neden RNN veya LSTM Değil?

docs/LIBRARY.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ model = OdyssNet(
3232
gate=None, # Default resolves to ['none', 'none', 'identity']
3333
vocab_size=None, # Optional: Decouples input/output size from neurons
3434
vocab_mode='hybrid', # 'hybrid', 'discrete', or 'continuous'
35-
hebb_type=None, # Optional: Plasticity resolution — None, 'global', 'neuron', or 'synapse'
35+
hebb_type=None, # Toggle: None, 'temporal', 'spatial', or 'both'
36+
hebb_res='neuron', # Plasticity resolution: 'global', 'neuron', or 'synapse'
3637
debug=False, # NaN/Inf diagnosis — raises RuntimeError at the first offending operation
3738
)
3839
```
@@ -66,22 +67,24 @@ model = OdyssNet(
6667
* `'continuous'`: Initializes only Linear Projection. Use for float-only inputs (e.g., vision, audio). Saves VRAM.
6768
* `tie_embeddings` (bool):
6869
* If `True`, ties the input embedding weights to the output decoder weights, saving significant VRAM and parameter count (Symmetric `vocab_size` only). Default is `False`.
69-
* `hebb_type` (str or None): Controls the structural resolution of **Heterogeneous Synaptic Plasticity**. Default is `None` (plasticity disabled).
70+
* `hebb_type` (str or None): Controls the active mechanism for **Heterogeneous Synaptic Plasticity**. Default is `None` (plasticity disabled).
71+
* `'temporal'`: STDP-style learning; correlates current state $h_t$ with previous state $h_{t-1}$.
72+
* `'spatial'`: Co-activation learning (classic Hebbian); correlates current state $h_t$ with itself $h_t$ (neurons firing simultaneously).
73+
* `'both'`: Combines both temporal and spatial mechanisms.
74+
* `hebb_res` (str): Controls the structural resolution of plasticity. Default is `'neuron'`.
7075

71-
| `hebb_type` | Parameter Shape | Extra Params | Mechanics |
76+
| `hebb_res` | Parameter Shape | Extra Params per Path | Mechanics |
7277
|---|---|---|---|
73-
| `None` || 0 | Disabled. |
7478
| `"global"` | scalar `()` | +2 | Uniform plasticity — the whole network is equally plastic. |
7579
| `"neuron"` | vector `(N,)` | +2N | Per-neuron plasticity — each neuron learns its own adaptation rate. |
7680
| `"synapse"` | matrix `(N, N)` | +2N² | Per-synapse plasticity — each connection has its own factor and decay. |
7781

78-
* Two learnable logit parameters are created according to the resolution:
79-
* `hebb_factor` (raw logit → `sigmoid` → learning rate ≈ 0.047 initially)
80-
* `hebb_decay` (raw logit → `sigmoid` → retention ≈ 0.90 initially)
81-
* During each forward pass the model accumulates temporal cross-neuron correlations $C_t = h_t \otimes h_{t-1}$ and applies them as $W_\text{eff} = W + (f_h \odot C_t)$ (where $f_h$ is `hebb_factor`), with $\odot$ element-wise multiplication broadcast to the chosen resolution.
82-
* The Hebbian state is persisted across forward calls via registered buffers (`hebb_state_W`, `hebb_state_mem`) and is cleared by `reset_state()`.
83-
* Both `hebb_factor` and `hebb_decay` are fully differentiable — gradients flow into them via the recurrent computation so the network **learns how to learn** online.
84-
* **Memory cost**: `"global"` adds negligible overhead; `"neuron"` adds $O(N)$; `"synapse"` triples total parameter count to $3N^2$.
82+
* For each active path (`t_` for temporal, `s_` for spatial), two learnable logit parameters are created according to the resolution:
83+
* `t_hebb_factor` / `s_hebb_factor` (raw logit → `sigmoid` → learning rate ≈ 0.047 initially)
84+
* `t_hebb_decay` / `s_hebb_decay` (raw logit → `sigmoid` → retention ≈ 0.90 initially)
85+
* During each forward pass the model accumulates correlations (temporal $h_t \otimes h_{t-1}$ and/or spatial $h_t \otimes h_t$) and applies them to the effective weights.
86+
* The Hebbian states are persisted across forward calls via registered buffers (`t_hebb_state_W`, `s_hebb_state_W`, etc.) and are cleared by `reset_state()`.
87+
* Both factors and decays are fully differentiable — gradients flow into them via the recurrent computation so the network **learns how to learn** online.
8588
* `gate` (None, str, or list[str]): Optional parametric gating mechanism. Default is `None`, which resolves to `['none', 'none', 'identity']`.
8689
* `None`: Default configuration with memory identity gate enabled, others disabled.
8790
* `str` (e.g., `'sigmoid'`): Applies the same gate activation to all three branches `[encoder_decoder, core, memory]`.

odyssnet/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "2.4.0"
1+
__version__ = "2.5.0"
22

33
from .core.network import OdyssNet
44
from .training.trainer import OdyssNetTrainer

0 commit comments

Comments
 (0)