Springe zum Hauptinhalt

Neurosimulator ANNarchy

ANNarchy (Artificial Neural Networks architect)

ANNarchy is a parallel simulator for distributed rate-coded or spiking neural networks. The definition of the network is declared in Python, but the library generates optimized C++ code to actually run the simulation in parallel, using either openMP (on multicore CPU architectures) or CUDA (on GPUs). The current stable version is 4.6 and is released under the GNU GPL v2 or later.

The code is available at:

https://github.com/ANNarchy/ANNarchy

The documentation is available at:

https://annarchy.github.io/

Core principles

ANNarchy separates the description of a neural network from its simulation. The description is declared in a Python script, offering high flexibility and readability of the code, and allowing to use the huge ecosystem of scientific libraries available with Python (Numpy, Scipy, Matplotlib, Sympy, Cython). Using Python furthermore reduces the programming effort to a minimum, letting the modeller concentrate on network design and data analysis.

A neural network is defined as a collection of interconnected populations of neurons. Each population comprises a set of similar artificial neurons (rate-coded or spiking point-neurons), whose activity is ruled by one or many ordinary differential equations. The activity of a neuron depends on the activity of other neurons through synapses, whose strength can evolve with time depending on pre- or post-synaptic activities (synaptic or plasticity). Populations are interconnected with each other through projections, which contain synapses between two populations.

ANNarchy provides a set of classical neuron or synapse models, but also allows the definition of specific models. The ordinary differential equations (ODE) governing neural or synaptic dynamics have to be specified by the modeler. Contrary to other simulators (except Brian) which require to code these modules in a low-level language, ANNarchy provides a mathematical equation parser which can generate optimized C++ code depending on the chosen parallel framework. Bindings from C++ to Python are generated thanks to Cython (C-extensions to Python), which is a static compiler for Python. These bindings allow the Python script to access all data generated by the simulation (neuronal activity, connection weights) as if they were simple Python attributes. However, the simulation itself is independent from Python and its relatively low performance.

Example of a pulse-coupled network of Izhikevich neurons

To demonstrate the simplicity of the interface of ANNarchy, here is the Hello, World! of spiking networks: the pulse-coupled network of Izhikevich neurons (Izhikevich, 2003). It can be defined in ANNarchy as:

from ANNarchy import *

# Create the excitatory and inhibitory population
pop = Population(geometry=1000, neuron=Izhikevich)
Exc = pop[:800]                 ; Inh = pop[800:]

# Set the population parameters
re = np.random.random(800)      ; ri = np.random.random(200)
Exc.noise = 5.0                 ; Inh.noise = 2.0
Exc.a = 0.02                    ; Inh.a = 0.02 + 0.08 * ri
Exc.b = 0.2                     ; Inh.b = 0.25 - 0.05 * ri
Exc.c = -65.0 + 15.0 * re**2    ; Inh.c = -65.0
Exc.d = 8.0 - 6.0 * re**2       ; Inh.d = 2.0
Exc.v = -65.0                   ; Inh.v = -65.0
Exc.u = Exc.v * Exc.b           ; Inh.u = Inh.v * Inh.b

# Create the projections
exc_proj = Projection(pre=Exc, post=pop, target='exc')
exc_proj.connect_all_to_all(weights=Uniform(0.0, 0.5))

inh_proj = Projection(pre=Inh, post=pop, target='inh')
inh_proj.connect_all_to_all(weights=Uniform(0.0, 1.0))

# Compile
compile()

# Start recording the spikes in the network to produce the plots
M = Monitor(pop, ['spike', 'v'])

# Simulate 1 second   
simulate(1000.0, measure_time=True)

# Retrieve the spike recordings and the membrane potential
spikes = M.get('spike')
v = M.get('v')

# Compute the raster plot
t, n = M.raster_plot(spikes)

# Compute the population firing rate
fr = M.histogram(spikes)

# Plot the results
import matplotlib.pyplot as plt
ax = plt.subplot(3,1,1)
ax.plot(t, n, 'b.', markersize=1.0)
ax = plt.subplot(3,1,2)
ax.plot(v[:, 15])
ax = plt.subplot(3,1,3)
ax.plot(fr)
plt.show()

Releases

  • 1.0: Initial version, purely C++.
  • 1.1: Management of exceptions.
  • 1.3: Parallelization of the computation using openMP.
  • 2.0: Optimized version with separated arrays for typed connections.
  • 2.1: Parallelization using CUDA.
  • 2.2: Optimized parallelization using openMP.
  • 3.0: Python interface to the C++ core using Boost::Python.
  • 4.0: Python-only version using Cython for the interface to the generated C++ code.

Associated projects

DFG project "Auto-tuning for neural simulations on different parallel hardware". HA2630/9-1 (2016-2019)

Selected Publications

Vitay, J., Dinkelbach, H., Hamker, F.H. (2015).
ANNarchy: a code generation approach to neural simulations on parallel hardware.
Frontiers in Neuroinformatics 9, 19. doi:10.3389/fninf.2015.00019

Dinkelbach, H., Vitay, J., Beuth, F., Hamker, F.H. (2012).
Comparison of GPU- and CPU-implementations of mean-firing rate neural networks on parallel hardware.
Network: Computation in Neural Systems, 23(4): 212-236. doi:10.3109/0954898X.2012.739292