Description of problem
I’m playing with voltage- and spike-time-dependent plasticity, aka Clopath et al. model. While LTD has a spike-train term with delta functions and can be moved to on_pre
resetting, LTP has all continuous variables and should be computed in a clock-driven manner. Both LTP and LTD use linear rectificatopn for voltage and low-pass filtered voltage.
where w_{ij} is a synaptic conductance from j^{th} presynaptic neuron to i^{th} postsynaptic. v is a voltage and S(t) = \sum \delta(t-t') is a spike train.
To make code a little faster, I moved computations of low pass filtered voltages and ReLU functions to the neuron side. So, part of my neuron equations looks like that
nrn_equ="""
.... neuron dynamics ....
dvlp/dt = (v-vlp)/tlpf_p : 1 # low-pass filter of the voltage for LTD
dvlm/dt = (v-vlm)/tlpf_m : 1 # low-pass filter of the voltage for LTP
vup = int(v>Tltp)*(v-Tltp) : 1
vlpup = int(vlp>Tltd)*(vlp-Tltd) : 1
vlmup = int(vlm>Tltd)*(vlm-Tltd) : 1
"""
Synaptic model can be implemented like this
syn = Synapses(lgninput, neurons, model="""
dwsyn/dt = Altp*x*vup_post*vlpup_post/tausynscal: 1 (clock-driven)
dx/dt = -x/tlpf_s : 1 (clock-driven) # slow presynaptic FR
dy/dt = -y/tfrest : 1 (clock-driven) # low-pass filter for FR estimate
""",
on_pre='''
x += 1*ms/tlpf_s
wsyn -= Altd*(y*second/tfrest/frRef)*vlmup_post
.... synaptic dynamics .....
''',
on_post='''
y += 1*ms/tfrest''')
This code works and works well.
============================
However, to debug my model, I want to separate LTP and LTD components and record them. So I modified synaptic equations like this:
syn = Synapses(lgninput, neurons, model="""
dwsyn/dt = LTP/tausynscal: 1 (clock-driven)
dx/dt = -x/tlpf_s : 1 (clock-driven) # slow presynaptic FR
dy/dt = -y/tfrest : 1 (clock-driven) # low-pass filter for FR estimate
LTP=Altp*x*vup_post*vlpup_post : 1
LTD : 1
""",
on_pre='''
x += 1*ms/tlpf_s
LTD = Altd*(y*second/tfrest/frRef)*vlmup_post
wsyn -= LTD
.... synaptic dynamics .....''',
on_post='''
y += 1*ms/tfrest''')
This code returns an error, which I don’t understand
ERROR Brian 2 encountered an unexpected error. If you think this is a bug in Brian 2, please report this issue either to the discourse forum at <http://brian.discourse.group/>, or to the issue tracker at <https://github.com/brian-team/brian2/issues>. Please include this file with debug information in your report: /tmp/brian_debug_8n4izity.log Additionally, you can also include a copy of the script that was run, available at: /tmp/brian_script_35ik7dpv.py Thanks! [brian2]
Traceback (most recent call last):
File "PLS-cortex.py", line 448, in <module>
onenrnpres_srec = StateMonitor(syn,"wsyn x y LTP LTD".split(),record=synids,dt=mth["/rec/cont/dt"]*ms)
File "/home/rth/.local/lib/python3.8/site-packages/brian2/monitors/statemonitor.py", line 248, in __init__
self.variables.add_reference(f'_source_{varname}',
File "/home/rth/.local/lib/python3.8/site-packages/brian2/core/variables.py", line 1829, in add_reference
self.add_referred_subexpression(name, group, var, index)
File "/home/rth/.local/lib/python3.8/site-packages/brian2/core/variables.py", line 1768, in add_referred_subexpression
self.add_referred_subexpression(new_name,
File "/home/rth/.local/lib/python3.8/site-packages/brian2/core/variables.py", line 1773, in add_referred_subexpression
self.add_reference(new_name,
File "/home/rth/.local/lib/python3.8/site-packages/brian2/core/variables.py", line 1821, in add_reference
raise TypeError(f"Cannot link variable '{name}' to '{varname}' in "
TypeError: Cannot link variable '___source_LTP_synapses_vup_post_synapses__vup_post_neurongroup_v' to '_vup_post_neurongroup_v' in group 'synapses' -- need to precalculate direct indices but index _postsynaptic_idx can change
It may be related to standalone OpenMP mode, I used to load all cores of my processor.
set_device('cpp_standalone')
prefs.devices.cpp_standalone.openmp_threads = npth