EvoBrain is an autonomous neuroevolutionary neural agent framework implemented in PyTorch. Unlike static neural networks that suffer from capacity bottlenecks or catastrophic forgetting, EvoBrain continuously evaluates its learning plateaus, self-triggers synaptic growth by dynamically allocating new hidden units while freezing/preserving pre-existing weights, and indexes its internal activations into a FAISS-backed subconscious memory store for historical experience retrieval.
-
Non-Destructive Synaptic Expansion: When training loss plateaus above the target tolerance (
$\mathcal{L} > \tau$ ), EvoBrain expands its hidden dimensionality ($d_{\text{hidden}} \to d_{\text{hidden}} + \Delta d$ ) dynamically in memory. Pre-trained weights are copied without perturbation, while new synaptic pathways are initialized using Kaiming normal distribution and zero-bias. -
Subconscious Vector Memory (FAISS L2): Extracts internal latent activations across batches to produce task fingerprints. Experiences are normalized and indexed in real-time into a high-speed L2 vector database, enabling the agent to query similar past scenarios before optimizing new tasks.
-
Dynamic Memory Realignment: When the agent's brain structure expands, the vector memory gracefully realigns its dimensionality to preserve seamless continual learning without interrupting execution.
-
Zero-Comment Pristine Codebase: Designed for production deployment with minimal clutter, modular class abstractions, and 100% comment-free executable pipelines.
The agent was evaluated across multiple autonomous lifecycle stages facing non-linear multi-variate tasks:
| Stage | Initial Hidden Dim | Final MSE Loss | Evolution Triggered | New Hidden Dim | Error Reduction |
|---|---|---|---|---|---|
| 1 | 16 units | 0.3760 | YES (Synaptic Growth) | 24 units | Baseline |
| 2 | 24 units | 0.0538 | NO (Converged) | 24 units | -85.7% |
| 3 | 24 units | 0.0094 | NO (Converged) | 24 units | -97.5% |
| 4 | 24 units | 0.0063 | NO (Converged) | 24 units | -98.3% |
| 5 | 24 units | 0.0053 | NO (Converged) | 24 units | -98.6% |
*Stage 1 plateaus at 0.3760 MSE (above 0.20 threshold). The agent triggers synaptic growth, adding 8 hidden units, precipitating an immediate 85.7% loss reduction in Stage 2 and continuing down to 0.0053 MSE (98.6% overall reduction).*
*Tracking L2 recall distance across life cycles: exact current-task registration ($L2 = 0.0$) alongside historical contextual memory retrieval ($L2 \in [1.17, 2.68]$).*
*Dual-axis visualization illustrating structural growth (16 to 24 units) and corresponding retrieval distance stabilization.*
*Benchmarking expansion increments $\Delta d \in \{4, 8, 16, 32\}$ against wall-clock runtime (seconds) and resulting network capacity.*
*L2 retrieval distance trajectories across lifecycle stages for different architectural expansion sizes.*
2D t-SNE Task Clusters
|
3D t-SNE (Initial Dim = 32)
|
3D t-SNE Low-Capacity Baseline (Initial Dim = 8)
|
|
Internal representations form distinct, geometrically well-separated task manifolds. Higher capacity configurations (Dim = 32) exhibit tighter cluster coherence than low-capacity baselines (Dim = 8).
SelfEvolvingModel/
βββ assets/ # Hero banner and publication figures
β βββ hero_banner.jpg
β βββ 01_training_loss_trend.png
β βββ 02_subconscious_memory_recall.png
β βββ 03_brain_structure_vs_retrieval.png
β βββ 04_expansion_speed_vs_scale.png
β βββ 05_retrieval_similarity_trends.png
β βββ 06_tsne_hidden_states_2d.png
β βββ 07_tsne_hidden_states_3d_dim8.png
β βββ 08_tsne_hidden_states_3d_dim32.png
βββ evo_brain/ # Modular Python package
β βββ __init__.py
β βββ brain.py # Dynamic EvolvingBrain architecture
β βββ memory.py # FAISS SubconsciousMemoryStore
β βββ task.py # Non-linear synthetic task generator
β βββ agent.py # Autonomous lifecycle orchestrator
β βββ visualizer.py # t-SNE and performance plotting suite
βββ notebooks/ # Interactive research notebook
β βββ Self_Evolving_Brain_NN.ipynb
βββ results/ # Generated artifacts and benchmarks
β βββ figures/ # Clean high-res exports
β βββ benchmark_summary.json # Machine-readable metric results
βββ tests/ # Automated unit test suite
β βββ __init__.py
β βββ test_evo_brain.py
βββ Self_Evolving_Brain_NN.ipynb # Clean, comment-free notebook
βββ self_evolving_brain.py # Single-file comment-free script
βββ run_simulation.py # CLI experimentation runner
βββ pyproject.toml # Package configuration
βββ requirements.txt # Project dependencies
βββ LICENSE # MIT License
βββ README.md # Project documentation
Clone the repository and install dependencies:
git clone https://github.com/CoderOggy78/SelfEvolvingModel.git
cd SelfEvolvingModel
pip install -r requirements.txtpython3 self_evolving_brain.pypython3 run_simulation.py --stages 5 --initial-hidden 16 --threshold 0.2 --expansion-size 8Open and execute the cleaned notebook:
jupyter notebook Self_Evolving_Brain_NN.ipynbimport torch
from evo_brain import AutonomousAgent, Visualizer
# Initialize autonomous agent
agent = AutonomousAgent(
input_dim=16,
initial_hidden=16,
target_threshold=0.2,
expansion_size=8
)
# Run autonomous lifecycle
records = agent.run_life_cycle(stages=5)
for r in records:
print(f"Stage {r['stage']}: Final Loss = {r['final_loss']:.4f} | Evolved: {r['evolved']}")Verify architecture integrity, weight preservation during synaptic expansion, and FAISS vector retrieval:
python3 -m unittest discover testsWhen expand_architecture(expansion_size) is called on EvolvingBrain:
- A new input projection tensor
$W_{\text{new}} \in \mathbb{R}^{(d_{\text{old}} + \Delta d) \times d_{\text{in}}}$ is allocated. - Existing weights are mapped:
$W_{\text{new}}[0:d_{\text{old}}, :] \leftarrow W_{\text{old}}$ . - New synaptic connections
$W_{\text{new}}[d_{\text{old}}:, :]$ are initialized via Kaiming normal distribution. - Output projection layer
$W_{\text{out}} \in \mathbb{R}^{d_{\text{out}} \times (d_{\text{old}} + \Delta d)}$ preserves prior connections:$W_{\text{out, new}}[:, 0:d_{\text{old}}] \leftarrow W_{\text{out, old}}$ . - New connections to outputs are initialized with zero-centered Gaussian distribution (
$\sigma = 0.01$ ).
This project is licensed under the MIT License.







