-
Notifications
You must be signed in to change notification settings - Fork 16
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
Summed post-synaptic variables accessed from synapse code #57
Comments
@schlowm0 - thanks for reminding about these issues. I have started to look into this but I am not quite sure any more what exactly it is you were after.
where
with two synaptic variables Case (1) we can support now fairly trivially. However, (2) would need some thinking and changes in GeNN itself I believe. @neworderofjamie, feel free to comment! |
Totally agree - 1 should be simple and 2 requires more work (as detailed in genn-team/genn#160) |
Thanks for looking into the issue again. Ie{input_number}_post = Ie_syn : amp (summed) where we assign for each synapttic projection a Iin = Ie0+Ii0 : amp # input currents So I believe if GeNN would offer an option that the underlying code takes care of the summation and thus do not throw an error when trying to sum at the synapses, it should be enough. At least if all to be summed variables are registered correctly. Note: We simulate the current-mode circuits of the analog neuromorphic chips of Giacomo, that's why we have currents as variables. |
So maybe to explain again why we opened this issue. I think that GeNN internally just throws an exception/error when the code performs summing operation as a safety switch to prevent execution of non-brian2 supported functionality. But in our toolbox we support this functionality and thus GeNN should not throw the exception. |
Ok, I think between @tnowotny and myself we understand the problem! After #82, you should be able to implement this by making the following changes to the model template (I'm afraid my Brian2GeNN knowledge doesn't go much further up the stack than this):
Then in the neuron code |
Just to clarify, would I need to do the change locally and do it every time a want to simulate a specific model? Because depending on the inputs we have more or less Ie's and Ii's... |
No, we need to sort this out internally in brian2genn. In addition to what Jamie wrote, we also need to change the code that detects which post-synaptic variables are targeted by which synapse group and then select the correct code path (still warning and aborting if two different synaptic variables are summed in the same synapse population - this remains a bottleneck). I will need Marcel's help but will have a look at this when I get a chance. In Capocaccia at the very latest. |
Hi, I'm happy to help from Brian2GeNN's side, but I'm not 100% sure I understand what you want to do. Do you want to have |
In our toolbox we implement a solution to register multiple inputs to be integrated on the same post-synaptic variable. I think it sees in our code that we have the summed flag at the synapses and that's why it throws an error. |
Ok, thanks for the clarification! |
So we need a mechanism/flag to tell |
Hi @mstimberg , my reading is that in order to support @schlowm0 's "hack", we need to allow separate synapse objects to target different post-synaptic neuron variables. This is something we can do in GeNN using the new GeNN syntax elements @neworderofjamie has pointed out. All that is missing is to detect within brian2genn that indeed only one synaptic variable per synapse object is summed and make sure that synapse objects either all create their own post-synaptic target variable (or all but one, who could use the standard "Isyn" variable). |
Ok, @mstimberg , I was a little on the wrong track here. The main problem appears to be that we need to simply support summed variables.
and to the
we should create
and add here: brian2genn/brian2genn/templates/model.cpp Line 95 in dc839f9
I think that should about do it. brian2genn/brian2genn/device.py Line 1249 in dc839f9
? It's probably trivial but I am still a bit lost in the Brian 2 code generation pathways. @neworderofjamie - any comments welcome from your side as well. |
Oh - and one more thing. We should also at some point in the code generation pipeline check that for a given Synapses object, in their totality all |
Hi, sorry, I didn't yet have much time to look into this.
I think we'll have to use the same approach as when we handle thresholds, resets, etc., i.e. "code objects" that are independently treated in Brian, but part of the neuron definition in GeNN. In the brian2genn/brian2genn/device.py Lines 404 to 414 in dc839f9
Later in brian2genn/brian2genn/device.py Lines 1101 to 1102 in dc839f9
All other checks can be done in |
Thanks ... that makes a lot of sense. Would the owner of a summed_variable template be an instance of a NeuronGroup? Otherwise we might have to duplicate the code for SynapseGroup owners ... |
For code like this: neurons = NeuronGroup(1, """dv/dt = (g-v)/(10*ms) : 1
g : 1""", method='exact')
S = Synapses(input, neurons,'''
dg_syn/dt = ... : 1 (clock-driven)
g_post = g_syn : 1 (summed)''') there will be a |
I think that's all - thanks a lot ... I will try to find some time to do the changes very soon. I think it should be quite easy after you provided this information (famous last words ...). |
So I tried your minimal working example @tnowotny and it worked :) I can confirm that it also works with the models provided within teili import os
import numpy as np
from brian2 import ms, nA, SpikeGeneratorGroup,\
SpikeMonitor, StateMonitor, prefs, set_device,\
asarray
import brian2genn
from teili import TeiliNetwork, Neurons, Connections
from teili import DPI, DPISyn
from teili.models.parameters.dpi_neuron_param import parameters as DPIparam
from teili import SynapseEquationBuilder
path = os.path.expanduser("~")
model_path = os.path.join(path, "teiliApps", "equations", "")
synapse_obj = SynapseEquationBuilder.import_eq(
model_path + 'DPISyn.py')
set_device('genn', use_GPU= False, directory='teili2genn_test', debug=True)
tsInp = asarray([1, 3, 4, 5, 6, 7, 8, 9]) * ms
indInp = asarray([0, 0, 0, 0, 0, 0, 0, 0])
gInpGroup = SpikeGeneratorGroup(1, indices=indInp,
times=tsInp, name='gtestInp')
Net = TeiliNetwork()
testNeurons = Neurons(2, equation_builder=DPI(num_inputs=2), name="testNeuron")
# Example of how to set parameters, saved as a dictionary
testNeurons.set_params(DPIparam)
testNeurons.refP = 3 * ms
testNeurons2 = Neurons(2, equation_builder=DPI(num_inputs=2), name="testNeuron2")
testNeurons2.refP = 3 * ms
InpSyn = Connections(gInpGroup, testNeurons,
equation_builder=synapse_obj,
name="testSyn", verbose=False)
InpSyn.connect(True)
InpSyn.weight = 10
Syn = Connections(testNeurons, testNeurons2,
equation_builder=synapse_obj,
name="testSyn2")
Syn.connect(True)
# you can change all the parameters like this after creation of the neurongroup:
Syn.weight = 100
# Example of how to set single parameters, rather than using an entire dictionary
testNeurons.Iconst = 10 * nA
Net.add(gInpGroup, testNeurons, testNeurons2, InpSyn, Syn)
duration = 500
Net.run(duration * ms) However, I encountered the following error when using Spike and/or Statemonitors which looks like this: NotImplementedError: Recording an expression that depends on the time t or the timestep dt is currently not supported in Brian2GeNN as this is not strictly related to this issue I opened a new issue #86 |
Allow this currently unsupported functionality of Brian 2, including targeting more than one post-synaptic variable in a summed fashion.
The text was updated successfully, but these errors were encountered: