Skip to main content

Crate neuromod

Crate neuromod 

Source
Expand description

§neuromod — Spiking neural network primitives

Biologically grounded SNN building blocks for Rust: a topology-neutral SpikingNetwork engine (LIF + Izhikevich banks), generic neuromodulators, classical STDP helpers, and reward-modulated STDP types.

Aimed at SNN / neuroscience readers learning Rust: equations and engine contracts first; idiomatic APIs second.

§Requirements

  • Rust 1.97.1+ (MSRV; also rust-version in Cargo.toml and rust-toolchain.toml).
  • Edition 2024.
  • CI-tested platforms: Linux, macOS, and Windows (GitHub Actions matrix).

§Syllabus (reading order on docs.rs)

  1. This page — engine vs standalone honesty and a quick start.
  2. engineSpikingNetwork and the per-tick SpikingNetwork::step contract.
  3. lif / izhikevich — the two banks the engine actually wires.
  4. modulators — dopamine / serotonin / acetylcholine / norepinephrine.
  5. rm_stdp / hebbian — plasticity building blocks (eligibility traces are not yet consumed by the live engine path; see those modules).
  6. Standalone models (lapicque, gif, fitzhugh_nagumo, hodgkin_huxley) for research use outside the engine.

§Engine vs standalone models

  • SpikingNetwork wires LIF and Izhikevich neuron banks only (with_dimensions(num_lif, num_izh, num_channels)).
  • Standalone types (LapicqueNeuron, GifNeuron, FitzHughNagumoNeuron, HodgkinHuxleyNeuron, …) are usable on their own; they are not alternate engine banks.
  • Plasticity: classical Hebbian STDP utilities plus EligibilityTrace / RmStdpConfig building blocks. Live step learning is dopamine-gated and updates LIF weights directly (not via eligibility conversion).

§Features

  • Topology-neutral, dynamically sized SpikingNetwork
  • Neuromodulators: dopamine, serotonin, acetylcholine, norepinephrine
use neuromod::{NeuroModulators, SpikingNetwork};

let mut network = SpikingNetwork::new();
let stimuli = [0.5f32; 16];
let modulators = NeuroModulators::default();
let output = network.step(&stimuli, &modulators).unwrap();
println!("Neurons that fired: {output:?}");

// Or build dynamically for larger architectures.
let mut large = SpikingNetwork::with_dimensions(518, 5, 518);
let large_input = vec![0.25f32; 518];
let _ = large.step(&large_input, &modulators).unwrap();

Re-exports§

pub use engine::SpikingNetwork;
pub use engine::StepError;
pub use fitzhugh_nagumo::FitzHughNagumoNeuron;
pub use gif::GifNeuron;
pub use hebbian::HebbianIzhikevichNetwork;
pub use hebbian::StdpParams;
pub use hebbian::apply_classical_stdp;
pub use hodgkin_huxley::HodgkinHuxleyNeuron;
pub use izhikevich::IzhikevichNeuron;
pub use lapicque::LapicqueNeuron;
pub use lif::LifNeuron;
pub use modulators::GenericReward;
pub use modulators::NeuroModulators;
pub use modulators::Observation;
pub use modulators::SignalProfile;
pub use modulators::UnitReward;
pub use modulators::apply_neuromodulation;
pub use rm_stdp::EligibilityTrace;
pub use rm_stdp::RmStdpConfig;

Modules§

engine
Engine — LIF + Izhikevich SpikingNetwork
fitzhugh_nagumo
FitzHugh-Nagumo neuron model (1961) — the classic 2D relaxation oscillator.
gif
Generalized Integrate-and-Fire (GIF) neuron model.
hebbian
Classical Hebbian learning module.
hodgkin_huxley
Hodgkin-Huxley neuron model (1952) — the biophysical gold standard.
izhikevich
Izhikevich neurons
lapicque
Lapicque (1907) Integrate-and-Fire neuron model — the biological root of all spiking neuron models.
lif
Leaky integrate-and-fire (LIF) neurons
modulators
Neuromodulators and domain-agnostic reward hooks
rm_stdp
R-STDP (Reward-modulated Spike-Timing-Dependent Plasticity) parameters.

Constants§

NUM_INPUT_CHANNELS
Number of input channels supported by default.