Skip to content
/ SNN Public

Spiking Neural Network (SNN) implementation designed for efficiency and biologically inspired computing. This project features event-driven neuron models, synaptic plasticity, and real-time spike-based learning. Optimized for low-power and high-speed processing,

Notifications You must be signed in to change notification settings

kleinpanic/SNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Spiking Neural Network Simulation

This project simulates a spiking neural network (SNN) using a terminal-based user interface built with the ncurses library. The simulation incorporates various biological phenomena such as conduction delays, background noise, synaptic plasticity via spike-timing dependent plasticity (STDP), and neurotransmitter dynamics, offering an insightful and interactive exploration of neural behavior.

Dependencies

To build and run this simulation, you will need:

  • GCC: A C compiler that supports C99 (or later).
  • ncurses Library: Used for the terminal-based user interface.
  • Math Library: Standard math functions (linked via -lm), e.g., for the exponential function.
  • Standard C Libraries: Such as stdlib.h, stdio.h, math.h, and time.h which are typically available on your system.

Installing Dependencies

On most Linux distributions, you can install ncurses using your package manager. For example:

# Debian/Ubuntu:
sudo apt-get install libncurses5-dev libncursesw5-dev

# Fedora:
sudo dnf install ncurses-devel

Installation

The provided Makefile automates the compilation process.

  1. Compile the Program:

Run the following command in the project directory:

make

This will compile the source file (SNN.c) into an executable (named snn by default).

  1. Compile in Debug Mode:

For debugging symbols, use:

make debug
  1. Run the Simulation:

After compiling, start the simulation by running:

    ./snn

The Science Behind the Simulation

This simulation models a simplified biological neural network using the integrate-and-fire model, where each neuron behaves as follows:

  • Integration: Neurons accumulate synaptic currents and external inputs over time.
  • Firing: When the membrane potential reaches a predefined threshold, the neuron fires (produces a spike), then resets its potential.
  • Refractory Period: After firing, neurons enter a refractory period during which they cannot fire again, mimicking biological recovery.
  • Leak: The membrane potential decays over time, simulating the natural leakage of charge in neurons.
  • Synaptic Plasticity (STDP): The simulation adjusts the strength of synaptic connections based on the relative timing of spikes, enabling learning-like behavior.

The Math Behind the Simulation

Several mathematical concepts form the backbone of this simulation:

  • Integrate-and-Fire Dynamics:

    • Neurons integrate inputs over time.
      • When the membrane potential VV reaches the threshold (V≥THRESHOLDV≥THRESHOLD), the neuron fires and resets to V=RESET_POTENTIALV=RESET_POTENTIAL.
  • Exponential Decay: * The potential decays each time step by a factor defined as LEAK_FACTORLEAK_FACTOR, simulating the natural leakage of ions.

  • Spike-Timing Dependent Plasticity (STDP): * Potentiation (LTP): When the pre-synaptic neuron fires shortly before the post-synaptic neuron: Δw=A+⋅e−Δtτ+ Δw=A+​⋅e−τ+​Δt​

  • Depression (LTD): When the post-synaptic neuron fires shortly before the pre-synaptic neuron: Δw=A−⋅e−Δtτ− Δw=A−​⋅e−τ−​Δt​ * These adjustments allow synapses to strengthen or weaken based on the timing of neuronal activity.

  • Conduction Delays:

    • Synaptic delays are incorporated to simulate the finite speed of neural signal propagation.
  • Noise:

    • Random background noise mimics the inherent variability observed in biological neural networks.

Why It’s Cool

* Real-Time Visualization: The ncurses-driven UI offers a dynamic, real-time view of neuronal activity directly in the terminal.
* Biologically Inspired: This simulation provides an accessible model of how real neurons communicate, learn, and adapt through STDP.
* Educational Value: It serves as a hands-on tool for understanding neural dynamics, integration, and the effect of synaptic plasticity.
* Customizability: With easily adjustable parameters and modular code, you can experiment with various aspects of neural behavior or extend the simulation to more complex models.
* Interactive Experience: Watch how neurons fire, how potentials evolve, and how synaptic weights change over time, all in a terminal-based environment.

Enjoy exploring the fascinating dynamics of spiking neural networks!

About

Spiking Neural Network (SNN) implementation designed for efficiency and biologically inspired computing. This project features event-driven neuron models, synaptic plasticity, and real-time spike-based learning. Optimized for low-power and high-speed processing,

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published