-
Notifications
You must be signed in to change notification settings - Fork 371
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
Rate neuron framework #745
Conversation
added models/ files for rate neurons
Siegert neuron
709a268
to
728436c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very impressive work.
So far, I have added some comment and requests, which are mostly referring to documentation issues.
models/diffusion_connection.h
Outdated
between neurons of type siegert_neuron. The connection type is identical to | ||
type rate_connection for instantaneous rate connections except for the two | ||
parameters "drift_factor" and "diffusion_factor" substituting the | ||
parameter "weight". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you could add one more sentence explaining the meaning of drift and diffusion in the context of the siegert neuron, i.e. that drift models the mean input to the neuron and diffusion the variance of input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. You need to provide the pertaining equations here. Are these factors K_ab w_ab and K_ab w_ab^2 from (28) and (29) in the paper, respectively?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestions. We added a detailed explanation. Note that these factor are quite general and not necessarily in the form of (28) and (29) in the paper.
models/diffusion_connection.h
Outdated
set_weight( double w ) | ||
{ | ||
throw BadProperty( | ||
"Please uses the parameters \"drift_factor\" and " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "uses" --> "use"
models/diffusion_connection.h
Outdated
// If the parameter weight is set, we throw a BadProperty | ||
if ( d->known( names::weight ) ) | ||
throw BadProperty( | ||
"Please uses the parameters \"drift_factor\" and " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "uses" --> "use"
models/diffusion_connection.h
Outdated
{ | ||
throw BadProperty( | ||
"Please uses the parameters \"drift_factor\" and " | ||
"\"diffusion_factor\" to specifiy the weights" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add '.' at end of sentence
models/diffusion_connection.h
Outdated
if ( d->known( names::weight ) ) | ||
throw BadProperty( | ||
"Please uses the parameters \"drift_factor\" and " | ||
"\"diffusion_factor\" to specifiy the weights" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add '.' at end of sentence
models/siegert_neuron.h
Outdated
non-linearity given by the gain function of the | ||
leaky-integrate-and-fire neuron with delta or exponentially decaying | ||
synapses. The model can be used for a mean-field analysis of spiking | ||
networks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps, a reference to a paper with the actual equations would be useful here?
For instance:
Fourcaud, Nicolas and Brunel, Nicolas, "Dynamics of the firing probability of noisy integrate-and-fire neurons", 14 (2002), pp. 2057--2110.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We added the reference.
models/siegert_neuron.cpp
Outdated
double mu, | ||
double sigma ) | ||
{ | ||
double alpha = 2.0652531522312172; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is the evaluation of the Riemann zeta function. Can you add a line comment explaining this briefly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I added an explanation of the variable alpha
|
||
# set up rate neuron and devices | ||
self.rate_neuron = nest.Create( | ||
'lin_rate_ipn', params=self.neuron_params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test only includes the input noise neuron. It would be straightforward to extend this to test the output noise neuron as well. Wouldn't this be a good idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is a good idea. We extended the test to output noise.
|
||
@nest.check_stack | ||
class RateNeuronCommunicationTestCase(unittest.TestCase): | ||
"""Check rate_neuron""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could extend this documentation by giving some more details, such as:
This test checks the correct function of rate neuron with input noise and three transfer functions. It also checks whether delay and weight of the rate connections work correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We updated the documentation according to your suggestions.
models/lin_rate.h
Outdated
The following parameters can be set in the status dictionary. | ||
|
||
rate double - Rate (unitless) | ||
tau double - Time constant in ms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the influence of the parameter tau in the model description above? The same for the other transfer functions, tanh and threshold_linear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the documentation a bit more specific stating that it is the time constant of rate dynamics.
@mschmidt87 Thank you for the first review and the valuable suggestions. So far I fixed the typos and the sli unittest. We will have a closer look on the other issues soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janhahne Impressive work! I have a number of comments including some issues on naming and design that would be good topics for the NEST Open Developer VC (@terhorstd).
models/delay_rate_connection.h
Outdated
|
||
|
||
/* BeginDocumentation | ||
Name: delay_rate_connection - Synapse type for rate connections with delay. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janhahne I am not really happy with the model name: It should be delayed_rate_connection
. Or, to group things better in the list of models, we should place delayed
at the end. For symmetry, we could then have
rate_connection_delayed
rate_connection_instantaneous
@terhorstd May you could discuss this in the Open Developer VC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heplesser I discussed this with @jschuecker and @ddahmen and we like and apply your second suggestion for renaming.
models/delay_rate_connection.h
Outdated
|
||
namespace nest | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove empty line.
models/delay_rate_connection.h
Outdated
* Class representing a delay-rate-connection. A delay-rate-connection | ||
* has the properties weight, delay and receiver port. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove empty line.
models/delay_rate_connection.h
Outdated
*/ | ||
|
||
template < typename targetidentifierT > | ||
class DelayRateConnection : public Connection< targetidentifierT > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you decide to change model names, adjust class names accordingly.
models/delay_rate_connection.h
Outdated
class DelayRateConnection : public Connection< targetidentifierT > | ||
{ | ||
|
||
double weight_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Remove empty line
- In NEST code, we generally place data members at the end, even though there are arguments for placing them first. Please move to the end for consistency.
- Add a doxygen comment for consistency, even though the name is quite clear.
models/siegert_neuron.cpp
Outdated
// propagate rate to new time step (exponential integration) | ||
double drive = siegert( P_.tau_m_ * 1e-3, | ||
P_.tau_syn_ * 1e-3, | ||
P_.t_ref_ * 1e-3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to scale the time values here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. The output of the function siegert is a rate in units of Hz. The NEST convention of time constants in ms would therefore give kHz for rates. We improved the conversion and shifted it to the return statement of the siegert functions.
models/siegert_neuron.cpp
Outdated
P_.theta_, | ||
P_.V_reset_, | ||
B_.drift_input_[ lag ], | ||
std::sqrt( B_.diffusion_input_[ lag ] ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the std::sqrt()
in the call here? Couldn't you just pass the variance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We followed your suggestion and pass the variance and convert it to the standard deviation later.
models/tanh_rate.h
Outdated
|
||
tanh_rate is an implementation of a non-linear rate model with either | ||
input (tanh_rate_ipn) or output noise (tanh_rate_opn) and gain function | ||
Phi(h) = tanh(g * h) and Psi(h) = h for linear_summation = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can the user only choose the gain, but not the location of the inflection point (tanh(gh-x))?.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We followed your suggestion, but implemented the function
tanh(g*(h-x))
nestkernel/event.h
Outdated
@@ -247,6 +250,16 @@ class Event | |||
void set_weight( weight t ); | |||
|
|||
/** | |||
* Set drift_factor of the event (see DiffusionEvent). | |||
*/ | |||
virtual void set_drift_factor( weight t ){}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use drift_weight
and diffusion_weight
as names, maybe?�
@terhorstd Discuss in VC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided in the NEST Open Developer VC to keep the old names.
nestkernel/event.h
Outdated
/** | ||
* Event for rate model connections without delay. | ||
*/ | ||
class RateNeuronEvent : public SecondaryEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How much of the code here could be moved to SecondaryEvent
? There seems quite a bit of overlap with other of these classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heplesser Yes, there is actually a lot of overlap and I am not particular happy about that. I already thought about how to reduce this overlap, but this is not that easy. Each class contains important individual static member variables, which are used in almost every function.
Let me explain in more detail: GapJunctionEvent
,RateNeuronEvent
,DelayRateNeuronEvent
and DiffusionEvent
all contain around 200 lines of code, but are more or less identical classes: All of them store arbitrary data of type std::vector<double>
. Therefore it would be much better to have one base class (e.g. DoubleVectorEvent
) of which all the other classes would be derived.
I could think of two approaches to achieve this:
1. use derived classes
The problem here is that derived classes do not have their own instance of the static variables. One possible solution ( http://stackoverflow.com/a/1390922 ) is to add a virtual function type& get_static()
to the base class and call the static variable only with this function. Then each derived class can define its own static variables and by overwriting the virtual get_static
function(s) they are also accessible for the functions of the base class.
This approach however does not work for us, as we also have a static function static void set_syn_id( const synindex synid )
in event classes (and in the potential base class) which calls one of the static variables. Calling this static variable with the get_static
function yields an cannot call member function without object
-error - which means that get_static
would have to be static as well, which is not possible as it is a virtual function.
- use a template class
Employ atemplate <typename something> class DoubleVectorEvent
with unused (but unique) template parameters. In this case each template class has its own static members. So one could define the events liketypedef DoubleVectorEvent<GapJunction> GapJunctionEvent
which would be nice as well. One (however solvable) problem here is the initialization of the static members. A much bigger problem is the operatorvoid DoubleVectorEvent::operator()()
which has to stay inevent.cpp
due to dependencies tonode.h
. A template definition of the class would however require to move the operator toevent.h
.
So for now we saw no solution to reduce the overhead here. If you have any suggestion they are of course very welcome!
Rate neuron framework
…est-simulator into rate-neuron-framework
Rate neuron framework
Rate neuron framework
@mschmidt87 @heplesser Thank you for the careful and detailed review. We finally addressed all of your comments. Please have another look. |
@janhahne Thank you for addressing my comments! I am still not entirely happy with the lack of encapsulation in event handling (see discussion on @jougs Since this is a major addition, I think it makes sense that a non-reviewer merges---would you do the honors? |
@heplesser I created a follow-up issue, see #806 @heplesser @mschmidt87 Thanks again to both of you for the detailed review! |
Due to this merge, master is currently failing. Probably it is not not related to the merge itself, but to the length of |
This PR adds rate models to NEST as described in
Hahne, J., Dahmen, D., Schuecker, J., Frommer, A.,
Bolten, M., Helias, M. and Diesmann, M. (2017).
Integration of Continuous-Time Dynamics in a
Spiking Neural Network Simulator.
Front. Neuroinform. 11:34. doi: 10.3389/fninf.2017.00034
Overview:
rate_neuron_ipn
) and outout noise (rate_neuron_opn
)rate_connection
for connections without delay,delay_rate_connection
for connections with delay anddiffussion_connection
for connection between siegert neurons)lin_rate
,tanh_rate
,thresholdlin_rate
)siegert_neuron
modelSecondaryEvent
s for different rate connectionWe suggest @heplesser as a reviewer