#!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 5.0 (5.0.0) 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 = dict(
parameters = 10.0,
tau_m = 5.0 ,
tau_e = -54.0 ,
vt = -60.0 ,
vr = -74.0 ,
El = 0.0 ,
Ee
),= [
equations 'tau_m * dv/dt = El - v + g_exc * (Ee - vr)', init = -60.0),
ann.Variable('tau_e * dg_exc/dt = - g_exc'),
ann.Variable(
],= "v > vt",
spike = "v = vr",
reset )
An input population of Poisson neurons, and a single post-synaptic neuron.
# Network
= ann.Network()
net
# Input population
= net.create(ann.PoissonPopulation(geometry=N, rates=F, name = 'Input'))
Input
# Output neuron
= net.create(geometry=1, neuron=IF, name = 'Output')
Output
# Projection learned using STDP
= net.connect(
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.all_to_all(weights
# Compile the network
compile() net.
Compiling network 1... OK
# Start recording
= net.monitor(Input, 'spike')
Mi = net.monitor(Output, 'spike')
Mo
# Start the simulation
=True)
net.simulate(duration, measure_time
# Retrieve the recordings
= Mi.get('spike')
input_spikes = Mo.get('spike') output_spikes
Simulating 100.0 seconds of the network 1 took 0.8422238826751709 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: 14.991800000000001
Mean firing rate of the output neuron: 26.110000000000003
=(12, 12))
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()