23#ifndef EPROP_SYNAPSE_H
24#define EPROP_SYNAPSE_H
220template <
typename target
identifierT >
356template <
typename target
identifierT >
372template <
typename target
identifierT >
376 , t_spike_previous_( 0 )
377 , previous_was_flush_event_( false )
378 , t_previous_trigger_spike_( 0 )
379 , optimizer_( nullptr )
383template <
typename target
identifierT >
390template <
typename target
identifierT >
393 , weight_( es.weight_ )
394 , optimizer_( es.optimizer_ )
399template <
typename target
identifierT >
408 ConnectionBase::operator=( es );
427template <
typename target
identifierT >
430 , weight_( es.weight_ )
431 , t_spike_previous_( es.t_spike_previous_ )
432 , previous_was_flush_event_( es.previous_was_flush_event_ )
433 , t_previous_trigger_spike_( es.t_previous_trigger_spike_ )
434 , z_bar_( es.z_bar_ )
435 , e_bar_( es.e_bar_ )
436 , e_bar_reg_( es.e_bar_reg_ )
437 , epsilon_( es.epsilon_ )
438 , z_previous_buffer_( es.z_previous_buffer_ )
439 , gradient_( es.gradient_ )
440 , remaining_steps_until_cutoff_( es.remaining_steps_until_cutoff_ )
441 , decay_steps_( es.decay_steps_ )
442 , optimizer_( es.optimizer_ )
445 es.optimizer_ =
nullptr;
449template <
typename target
identifierT >
458 ConnectionBase::operator=( es );
460 weight_ = es.weight_;
461 t_spike_previous_ = es.t_spike_previous_;
462 previous_was_flush_event_ = es.previous_was_flush_event_;
463 t_previous_trigger_spike_ = es.t_previous_trigger_spike_;
466 e_bar_reg_ = es.e_bar_reg_;
467 epsilon_ = es.epsilon_;
468 z_previous_buffer_ = es.z_previous_buffer_;
469 gradient_ = es.gradient_;
470 remaining_steps_until_cutoff_ = es.remaining_steps_until_cutoff_;
471 decay_steps_ = es.decay_steps_;
472 optimizer_ = es.optimizer_;
475 es.optimizer_ =
nullptr;
480template <
typename target
identifierT >
484 size_t receptor_type,
488 if ( get_delay_steps() != 1 )
490 throw IllegalConnection(
"eprop synapses currently require a delay of one simulation step" );
494 ConnectionBase::check_connection_( dummy_target, s, t, receptor_type );
501template <
typename target
identifierT >
509template <
typename target
identifierT >
513 Node* target = get_target( thread );
516 const long t_spike = e.get_stamp().get_steps();
517 const bool is_flush_event = e.is_flush_event();
519 if ( t_spike_previous_ != 0 )
521 target->compute_gradient( t_spike,
532 previous_was_flush_event_,
534 remaining_steps_until_cutoff_,
538 target->erase_used_eprop_history( t_spike, t_spike_previous_ );
540 t_spike_previous_ = t_spike;
541 previous_was_flush_event_ = is_flush_event;
543 if ( not is_flush_event )
545 e.set_receiver( *target );
546 e.set_weight( weight_ );
547 e.set_delay_steps( get_delay_steps() );
548 e.set_rport( get_rport() );
554template <
typename target
identifierT >
558 ConnectionBase::get_status( d );
567 optimizer_->get_status( optimizer_dict );
572template <
typename target
identifierT >
576 ConnectionBase::set_status( d, cm );
591 if ( weight_ < epcp.optimizer_cp_->get_Wmin() )
593 throw BadProperty(
"Minimal weight Wmin ≤ weight required." );
596 if ( weight_ > epcp.optimizer_cp_->get_Wmax() )
598 throw BadProperty(
"weight ≤ maximal weight Wmax required." );
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition exceptions.h:680
Class containing the common properties for all connections of a certain type.
Definition common_synapse_properties.h:50
Base class for dummy nodes used in connection testing.
Definition connection.h:67
Base class for representing connections.
Definition connection.h:110
long get_delay_steps() const
Return the delay of the connection in steps.
Definition connection.h:181
Node * get_target(const size_t tid) const
Definition connection.h:239
size_t get_rport() const
Definition connection.h:244
double get_delay() const
Return the delay of the connection in ms.
Definition connection.h:172
Definition connector_model.h:69
Homogeneous connector, contains synapses of one particular type (syn_id_).
Definition connector_base.h:221
"Callback request event" for use in Device.
Definition event.h:521
Base class implementing common properties for e-prop synapses with additional biological features.
Definition eprop_synapse.h:165
WeightOptimizerCommonProperties * optimizer_cp_
Pointer to common properties object for weight optimizer.
Definition eprop_synapse.h:190
~EpropSynapseCommonProperties()
Destructor.
Definition eprop_synapse.cpp:49
EpropSynapseCommonProperties & operator=(const EpropSynapseCommonProperties &)=delete
Assignment operator.
EpropSynapseCommonProperties()
Definition eprop_synapse.cpp:37
void get_status(Dictionary &d) const
Get parameter dictionary.
Definition eprop_synapse.cpp:55
void set_status(const Dictionary &d, ConnectorModel &cm)
Update values in parameter dictionary.
Definition eprop_synapse.cpp:65
Encapsulate information sent between nodes.
Definition event.h:103
Definition connector_model.h:152
To be thrown if a connection is not possible.
Definition exceptions.h:490
Base class for all NEST network objects.
Definition node.h:99
virtual void register_eprop_connection()
Registers an eprop connection.
Definition node.cpp:217
Event for spike information.
Definition event.h:418
Base class implementing common properties of a weight optimizer model.
Definition weight_optimizer.h:154
virtual WeightOptimizer * get_optimizer() const =0
Get optimizer.
Base class implementing a weight optimizer model.
Definition weight_optimizer.h:238
Dummy node for testing the connection.
Definition eprop_synapse.h:277
size_t handles_test_event(SpikeEvent &, size_t)
Check if the node can handle a particular event and receptor type.
Definition eprop_synapse.h:282
size_t handles_test_event(DSSpikeEvent &, size_t)
Definition eprop_synapse.h:288
Class implementing a synapse model for e-prop plasticity with additional biological features.
Definition eprop_synapse.h:222
Connection< targetidentifierT > ConnectionBase
Type of the connection base.
Definition eprop_synapse.h:229
double z_bar_
Low-pass filtered spiking variable.
Definition eprop_synapse.h:325
double weight_
Synaptic weight.
Definition eprop_synapse.h:313
static constexpr bool supports_flush_event
Whether this connection type supports flush events.
Definition eprop_synapse.h:241
EpropSynapseCommonProperties CommonPropertiesType
Type of the common synapse properties.
Definition eprop_synapse.h:226
double epsilon_
Adaptive threshold component of the eligibility vector.
Definition eprop_synapse.h:334
double gradient_
Sum of gradients.
Definition eprop_synapse.h:340
eprop_synapse & operator=(const eprop_synapse &)
Assignment operator.
Definition eprop_synapse.h:401
long remaining_steps_until_cutoff_
Remaining computation steps.
Definition eprop_synapse.h:343
long t_previous_trigger_spike_
The time step when the spike arrived that triggered the previous e-prop update.
Definition eprop_synapse.h:322
void set_status(const Dictionary &d, ConnectorModel &cm)
Update values in parameter dictionary.
Definition eprop_synapse.h:574
void set_weight(const double w)
Set the synaptic weight to the provided value.
Definition eprop_synapse.h:303
~eprop_synapse()
Destructor.
Definition eprop_synapse.h:384
bool previous_was_flush_event_
Previous event was a flush event.
Definition eprop_synapse.h:319
double z_previous_buffer_
Value of spiking variable one time step before t_previous_spike_.
Definition eprop_synapse.h:337
eprop_synapse()
Default constructor.
Definition eprop_synapse.h:373
WeightOptimizer * optimizer_
Optimizer.
Definition eprop_synapse.h:353
void get_status(Dictionary &d) const
Get parameter dictionary.
Definition eprop_synapse.h:556
double e_bar_reg_
Low-pass filtered eligibility trace for firing rate regularization.
Definition eprop_synapse.h:331
void delete_optimizer()
Delete optimizer.
Definition eprop_synapse.h:503
static constexpr ConnectionModelProperties properties
Properties of the connection model.
Definition eprop_synapse.h:236
long decay_steps_
Decay steps for the eligibility trace.
Definition eprop_synapse.h:346
long t_spike_previous_
The time step when the previous spike arrived.
Definition eprop_synapse.h:316
double e_bar_
Low-pass filtered eligibility trace.
Definition eprop_synapse.h:328
bool send(Event &e, size_t thread, const EpropSynapseCommonProperties &cp)
Send the spike event.
Definition eprop_synapse.h:511
void check_connection(Node &s, Node &t, size_t receptor_type, const CommonPropertiesType &cp)
Check if the target accepts the event and receptor type requested by the sender.
Definition eprop_synapse.h:482
virtual size_t handles_test_event(SpikeEvent &, size_t receptor_type)
Check if the node can handle a particular event and receptor type.
Definition node.cpp:271
const std::string optimizer("optimizer")
const std::string weight("weight")
const std::string size_of("sizeof")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_eprop_synapse(const std::string &name)
Register the eprop synapse model.
Definition eprop_synapse.cpp:32
ConnectionModelProperties
Definition connector_model.h:49
@ REQUIRES_EPROP_ARCHIVING
constexpr size_t invalid_port
Value for invalid connection port number.
Definition nest_types.h:141