Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pole balancing/reinforcement learning tutorial #1151

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e57bf90
Added Polebalancing directory in doc/tutorials
Dec 12, 2024
f450731
add first draft for spiking neural network
Jan 6, 2025
e11f83b
Changed datastructure to flat iterator and implemented index lookup f…
Jan 9, 2025
d11ade7
generate NESTML model code
Jan 9, 2025
b5c6dd4
generate NESTML model code
Jan 9, 2025
9a1e63c
updates on spiking controller
Jan 13, 2025
89c8302
Added heatmap for q-values, added better simulation control, experime…
Jan 16, 2025
eb3b591
Some code cleanup
Jan 17, 2025
c9c4834
fixed typo
Jan 17, 2025
8d2a1b4
more questions and mysteries
Jan 23, 2025
fc1dc6a
some stuff
Jan 23, 2025
d22a549
Connected SNN and physics simulation, cleaned up some code, added som…
Jan 29, 2025
8253663
Added some plots
Feb 6, 2025
85bce12
input now scatterplot, added neuron_test notebook
Feb 9, 2025
26a8ee0
Added synapse test notebook
Feb 9, 2025
a3d8a88
Merge remote-tracking branch 'upstream/master' into cart_pole_tutorial
Feb 18, 2025
008be08
fix discretisation bug; cleaned up notebook
Feb 18, 2025
290cae0
cleaned up notebook
Feb 19, 2025
4dbcc6d
cleaned up notebook
Feb 19, 2025
d8bf999
Added step-by-step simulation, added network storing
Mar 11, 2025
806a2ee
Merge remote-tracking branch 'upstream/master' into cart_pole_tutorial
Mar 11, 2025
b563db6
Merge branch 'cart_pole_tutorial' of https://github.com/AlexisWis/nes…
Mar 11, 2025
79f5cd4
Removed small debug code
Mar 11, 2025
dc6c394
Merge remote-tracking branch 'origin/cart_pole_tutorial' into cart_po…
Mar 11, 2025
75d4cc6
fix SNN
Mar 12, 2025
93498f8
fixed boxes according to Liu&Pan code
Mar 14, 2025
8ca8491
SNN updates
Mar 20, 2025
047415c
SNN updates
Mar 20, 2025
3318fbe
SNN updates
Mar 20, 2025
bcb1791
SNN updates
Mar 20, 2025
022abb6
fix SNN
Mar 26, 2025
962a1a1
fix SNN
Mar 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# iaf_psc_exp - Leaky integrate-and-fire neuron model
# ###################################################
#
# Description
# +++++++++++
#
# ...
#
#
# References
# ++++++++++
#
# ...
#
# See also
# ++++++++
#
model iaf_psc_exp_neuron:

state:
V_m mV = E_l # Membrane potential
g_e real = 0.

equations:
g_e' = -g_e / tau_g
V_m' = (g_e * (E_e - V_m) + E_l - V_m + I_e + I_stim) / tau_m

parameters:
tau_m ms = 10 ms # Membrane time constant
tau_g ms = 5 ms
E_e mV = 0 mV
E_l mV = -74 mV # Resting potential
V_th mV = -54 mV # Spike threshold potential
V_reset mV = -60 mV

# constant external input current
I_e real = 0

#scaling factor for incoming spikes
s real = 1000

input:
spikes_in_port <- spike
I_stim real <- continuous

output:
spike

update:
integrate_odes()

onReceive(spikes_in_port):
g_e += spikes_in_port * s

onCondition(V_m >= V_th):
# threshold crossing
V_m = V_reset
emit_spike()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# stdp - Synapse model for spike-timing dependent plasticity
# ##########################################################
#
# ...
#
model neuromodulated_stdp_synapse:
state:
w real = 1 # Synaptic weight
wtr real = 0
pre_trace real = 0.
post_trace real = 0.

parameters:
n real = 0. # neuromodulator concentration between 0 and 1
d ms = 1 ms # Synaptic transmission delay
beta real = 0.01 # learning rate
tau_tr_pre ms = 20 ms
tau_tr_post ms = 20 ms
pre_trace_increment real = 1.
post_trace_increment real = 1.
wtr_max real = 0.1
wtr_min real = 0

equations:
pre_trace' = -pre_trace / tau_tr_pre
post_trace' = -post_trace / tau_tr_post

input:
pre_spikes <- spike
post_spikes <- spike

output:
spike(weight real, delay ms)

onReceive(post_spikes):
post_trace += -1.05E-7 # XXX FIXME!!!! should be ``+= post_trace_increment``

wtr += pre_trace
wtr = max(wtr_min, wtr)
wtr = min(wtr_max, wtr)

onReceive(pre_spikes):
pre_trace += pre_trace_increment

wtr += post_trace
wtr = max(wtr_min, wtr)
wtr = min(wtr_max, wtr)

# deliver spike to postsynaptic partner
emit_spike(w, d)

update:
integrate_odes()
2,652 changes: 2,652 additions & 0 deletions doc/tutorials/cart_pole_reinforcement_learning/neuron_test.ipynb

Large diffs are not rendered by default.

Loading
Loading