This repository contains a Brian2-based hybrid neuromorphic framework that combines analog and digital neurons. It includes: a minimal end‑to‑end demo, an experiments harness (noise, jitter, ablation), and a long‑run consolidation/saturation study. This README explains what each file does and how to reproduce all figures for your paper.
Create a virtual environment and install dependencies:
python -m venv .venv
.\.venv\Scripts\Activate
pip install brian2 numpy matplotlibClone/open this repo, then run the scripts below from their folders as shown.
- AnalogAndDigital_Final/
main_file.py– Minimal end‑to‑end demo of the hybrid architecture (2 analog + 2 digital neurons) with configurable synaptic plasticity (Hebb, STDP, LTP), basic energy estimation, noise adaptability visualization, and non‑volatile memory export (nv_memory.json). Produces interactive plots (not saved to disk by default).
- Review/
update.py– Experiments harness that reproduces noise robustness, timing/jitter, and ablation results. Saves three PDFs in the same folder:fig_noise_sweep_updated.pdffig_jitter_test_updated.pdffig_ablation_updated.pdf
saturation.py– Long‑run LTM consolidation/saturation tests with multiple conditions (baseline/full/decay_only/norm_only). Saves plots toReview/saturation_results/:fig_saturation_norm.pdf(||W|| over time)fig_saturation_hist.pdf(weight histograms at t0/tmid/tend)fig_saturation_perf.pdf(mean firing rate over time)
saturation_results/– Output directory created bysaturation.py.
- AnalogAndDigital_Older/ – Earlier variants kept for reference.
From the AnalogAndDigital_Final folder:
cd AnalogAndDigital_Final
python main_file.pyWhat you’ll see/produce:
- Interactive figures: analog/digital voltage traces, synaptic weight evolution (one synapse 0→1), spike rasters, energy comparison bar chart, and noise adaptability curves.
- A JSON snapshot
nv_memory.jsoncontaining neuron states and synaptic weights.
Choosing the learning rule:
- Open
main_file.pyand set the call in__main__:run_dual_mode_dual_neuron(learning_rule='hebb' | 'stdp' | 'ltp')
- Implemented behaviors:
- Hebb (demo form): additive potentiation on pre‑spike,
w = clip(w + 0.01*mV, 0, 1*mV)→ approximately linear growth until capped. - STDP (pair-based): uses pre/post traces with balanced potentiation/depression, clipped to
w_max. - LTP (bounded multiplicative):
w += α (w_max − w)clipped to[0, w_max]→ concave growth that slows near the ceiling.
- Hebb (demo form): additive potentiation on pre‑spike,
Notes for reproducing a strictly linear Hebbian figure (as in the paper):
- Plot right after the initial 1000 ms run (before any subsequent noise runs); otherwise additional runs will change the slope and produce curvature.
From the Review folder:
cd Review
python update.pyOutputs (saved in Review/):
fig_noise_sweep_updated.pdf– Mean ± SD accuracy vs. input noise (analog vs. digital)fig_jitter_test_updated.pdf– First‑spike latency vs. jitterfig_ablation_updated.pdf– Perturbation response with/without adaptive synapse
Each experiment builds a fresh network per trial and uses fixed time step dt = 0.1 ms for reproducibility.
From the Review folder:
cd Review
python saturation.pyOutputs (saved in Review/saturation_results/):
fig_saturation_norm.pdf– L2 norm of weights across consolidation stepsfig_saturation_hist.pdf– Weight distributions at different timesfig_saturation_perf.pdf– Population mean firing rate (Hz)
The script runs multiple seeds and conditions and writes all figures to a dedicated results directory.
- Randomness: Some scripts set seeds internally (see
saturation.py). For exact replication of figures, run the scripts from their own folders and avoid editing seeds unless required by the paper. - Units: Brian2 enforces physical units. All weight updates are bounded via
clip(..., 0*mV, w_max)where applicable to avoid runaway growth. - Plot fonts:
main_file.pysets global Matplotlib font sizes for readability. PDFs produced byReviewscripts embed the font sizes present at runtime.
- “My Hebbian curve looks curved, not linear”: Ensure you’re plotting the segment from the initial 1000 ms run only. Later noise/adaptive runs (after
net.store()/restore()) can change firing rates and bend the trajectory. - “Different curves look too similar”: If rules saturate at the same ceiling and runtime is long, all curves flatten near
w_max. Reduce runtime or lowerw_maxto highlight differences, or compare multiple synapses with different spike correlations. - Windows tip: Run each script from its own folder so that PDFs and
nv_memory.jsonare written to the expected locations.
- Dual‑mode neurons: analog (variability/adaptability) and digital (precision timing)
- Configurable plasticity rules:
- Hebbian learning
- Spike‑timing‑dependent plasticity (STDP)
- Long‑term potentiation (LTP)
- Python 3.8+ (3.10/3.11 recommended)
- Brian2
- NumPy
- Matplotlib
- JSON (standard library)
Use Windows PowerShell commands (or adapt to your shell):
git clone https://github.com/Emir2099/BRIAN2.git
cd BRIAN2
python -m venv .venv
.\.venv\Scripts\Activate
pip install brian2 numpy matplotlibThe code generates several plots:
- Membrane potential traces for analog and digital neurons
- Synaptic weight evolution over time
- Spike raster plots
- Energy efficiency comparison
- Noise adaptability analysis
- Edge AI: low‑power wearable devices
- Autonomous robotics: systems requiring persistent skill retention
- Neuromorphic hardware: RRAM‑integrated chips
- Brain‑inspired computing: models bridging biological plausibility and engineering pragmatism
- Brian2 development team
- Neuromorphic computing community