#!pip install ANNarchy
STDP - network
A simple model showing the STDP learning rule on inputs converginf to a single neuron. Model adapted from Song, Miller and Abbott (2000) and Song and Abbott (2001)
Code adapted from the Brian example: http://brian.readthedocs.org/en/1.4.1/examples-plasticity_STDP1.html
import numpy as np
import matplotlib.pyplot as plt
import ANNarchy as ann
ANNarchy 4.8 (4.8.2) on darwin (posix).
Some parameters:
= 15.0 # Poisson distribution at 15 Hz
F = 1000 # 1000 Poisson inputs
N = 0.01 # Maximum weight
gmax = 100000.0 # Simulation for 100 seconds duration
Integrate-and-fire neuron:
= ann.Neuron(
IF = """
parameters tau_m = 10.0
tau_e = 5.0
vt = -54.0
vr = -60.0
El = -74.0
Ee = 0.0
""",
= """
equations tau_m * dv/dt = El - v + g_exc * (Ee - vr) : init = -60.0
tau_e * dg_exc/dt = - g_exc
""",
= """
spike v > vt
""",
= """
reset v = vr
"""
)
An input population of Poisson neurons, and a single post-synaptic neuron.
# Input population
= ann.PoissonPopulation(name = 'Input', geometry=N, rates=F)
Input
# Output neuron
= ann.Population(name = 'Output', geometry=1, neuron=IF)
Output
# Projection learned using STDP
= ann.Projection(
proj = Input,
pre = Output,
post = 'exc',
target = ann.STDP(tau_plus=20.0, tau_minus=20.0, A_plus=0.01, A_minus=0.0105, w_max=0.01)
synapse
)=ann.Uniform(0.0, gmax))
proj.connect_all_to_all(weights
# Compile the network
compile() ann.
Compiling ... OK
# Start recording
= ann.Monitor(Input, 'spike')
Mi = ann.Monitor(Output, 'spike')
Mo
# Start the simulation
=True)
ann.simulate(duration, measure_time
# Retrieve the recordings
= Mi.get('spike')
input_spikes = Mo.get('spike') output_spikes
Simulating 100.0 seconds of the network took 0.48438501358032227 seconds.
# Compute the mean firing rates during the simulation
print('Mean firing rate in the input population: ' + str(Mi.mean_fr(input_spikes)) )
print('Mean firing rate of the output neuron: ' + str(Mo.mean_fr(output_spikes)) )
# Compute the instantaneous firing rate of the output neuron
= Mo.smoothed_rate(output_spikes, 100.0)
output_rate
# Receptive field after simulation
= proj.w[0] weights
Mean firing rate in the input population: 15.0327
Mean firing rate of the output neuron: 26.99
=(12, 10))
plt.figure(figsize3,1,1)
plt.subplot('Firing rate')
plt.title(0, :])
plt.plot(output_rate[3,1,2)
plt.subplot('Weights')
plt.title('.')
plt.plot(weights, 3,1,3)
plt.subplot('Weights histogram')
plt.title(=20)
plt.hist(weights, bins plt.show()