From be4e23988528fea0db9fee6ba76abe3cac3cc093 Mon Sep 17 00:00:00 2001 From: Harsh Khilawala Date: Wed, 24 Jul 2024 17:36:33 -0400 Subject: [PATCH 1/3] add eprop-iaf-adapt NEST model --- pyNN/nest/standardmodels/cells.py | 26 ++++++++++++++++ pyNN/standardmodels/cells.py | 52 +++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/pyNN/nest/standardmodels/cells.py b/pyNN/nest/standardmodels/cells.py index b2a2150d..fb591213 100644 --- a/pyNN/nest/standardmodels/cells.py +++ b/pyNN/nest/standardmodels/cells.py @@ -396,6 +396,32 @@ class EIF_cond_exp_isfa_ista(cells.EIF_cond_exp_isfa_ista): "off_grid": "aeif_cond_exp"} standard_receptor_type = True +class IF_eprop_adaptive(cells.IF_eprop_adaptive): + + __doc__ = cells.IF_eprop_adaptive.__doc__ + + translations = build_translations( + ('adapt_beta', 'adapt_beta'), + ('adapt_tau', 'adapt_tau'), + ('cm', 'C_m', 1000.0), # nF -> pF + ('c_reg', 'c_reg'), + ('v_rest', 'E_L'), + ('f_target', 'f_target'), + ('gamma', 'gamma'), + ('i_offset', 'I_e', 1000.0), # nA -> pA + ('reg_spike_arr', 'regular_spike_arrival'), + ('surrogate_gradient_function', 'surrogate_gradient_function'), + ('tau_refrac', 't_ref'), + ('tau_m', 'tau_m'), + ('v_min', 'V_min'), + ('v_thresh', 'V_th'), + ) + variable_map = {'v': 'V_m', 'v_th_adapt': 'V_th_adapt', 'adaptation': 'adaptation', 'learning_signal': 'learning_signal', 'surrogate_gradient': 'surrogate_gradient'} + scale_factors = {'v': 1, 'v_th_adapt': 1, 'adaptation': 1, 'learning_signal': 1, 'surrogate_gradient': 1} + nest_name = {"on_grid": "eprop_iaf_adapt_bsshslm_2020", + "off_grid": "eprop_iaf_adapt_bsshslm_2020"} + standard_receptor_type = True + class Izhikevich(cells.Izhikevich): __doc__ = cells.Izhikevich.__doc__ diff --git a/pyNN/standardmodels/cells.py b/pyNN/standardmodels/cells.py index 608f213f..2b34fdbf 100644 --- a/pyNN/standardmodels/cells.py +++ b/pyNN/standardmodels/cells.py @@ -684,6 +684,58 @@ def computed_parameters_include(self, parameter_names): for psr in self.post_synaptic_receptors.values()]) ) +class IF_eprop_adaptive(StandardCellType): + """ + Implementation of a leaky integrate-and-fire neuron model with delta-shaped + postsynaptic currents and threshold adaptation used for + eligibility propagation (e-prop) plasticity. + + Bellec G, Scherr F, Subramoney F, Hajek E, Salaj D, Legenstein R, Maass W (2020). + A solution to the learning dilemma for recurrent networks of spiking neurons. + Nature Communications, 11:3625. https://doi.org/10.1038/s41467-020-17236-y + """ + + default_parameters = { + 'adapt_beta': 1.0, # Prefactor of threshold adaptation + 'adapt_tau': 10.0, # Time constant of threshold adaptation in ms + 'cm': 0.250, # Membrane capacitance in nF + 'c_reg': 0.0, # Regularization factor + 'v_rest': -70.0, # Resting membrane potential in mV + 'f_target': 10.0, # Target firing rate of regularization factor in Hz + 'gamma': 0.3, # Scaling of surrogate gradient + 'i_offset': 0.0, # Offset current in nA + 'reg_spike_arr': True, # Regularize spike arrival times + 'surrogate_gradient_function': 'piecewise_linear', # Surrogate gradient function + 'tau_refrac': 2.0, # Refractory period in ms + 'tau_m': 10.0, # Membrane time constant in ms + 'v_min': -1.79e308, # Minimum membrane potential in mV + 'v_thresh': -55.0, # Spike threshold in mV + } + + recordable = ['v', 'spikes', 'adaptation', 'v_th_adapt', 'learning_signal', 'surrogate_gradient'] + + default_initial_values = { + 'adaptation': 0.0, # Adaptation variable + 'learning_signal': 0.0, # Learning signal + 'surrogate_gradient': 0.0, # Surrogate gradient + 'v': -70.0, # Membrane potential + 'v_th_adapt': -55.0, # Threshold adaptation variable + } + + units = { + 'adapt_tau': 'ms', + 'cm': 'nF', + 'v_rest': 'mV', + 'f_target': 'Hz', + 'i_offset': 'nA', + 't_ref': 'ms', + 'tau_m': 'ms', + 'v_min': 'mV', + 'v_thresh': 'mV', + 'v': 'mV', + 'v_th_adapt': 'mV', + } + class Izhikevich(StandardCellType): """ From f85a71d8070c68f04c7fbd2d19bee8d4da865dbf Mon Sep 17 00:00:00 2001 From: Harsh Khilawala Date: Wed, 24 Jul 2024 17:56:14 -0400 Subject: [PATCH 2/3] add eprop-iaf NEST model --- pyNN/nest/standardmodels/cells.py | 28 ++++++++++++++++++ pyNN/standardmodels/cells.py | 49 +++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/pyNN/nest/standardmodels/cells.py b/pyNN/nest/standardmodels/cells.py index fb591213..13f9e68c 100644 --- a/pyNN/nest/standardmodels/cells.py +++ b/pyNN/nest/standardmodels/cells.py @@ -396,6 +396,7 @@ class EIF_cond_exp_isfa_ista(cells.EIF_cond_exp_isfa_ista): "off_grid": "aeif_cond_exp"} standard_receptor_type = True + class IF_eprop_adaptive(cells.IF_eprop_adaptive): __doc__ = cells.IF_eprop_adaptive.__doc__ @@ -423,6 +424,33 @@ class IF_eprop_adaptive(cells.IF_eprop_adaptive): standard_receptor_type = True +class IF_eprop(cells.IF_eprop_adaptive): + + __doc__ = cells.IF_eprop.__doc__ + + translations = build_translations( + ('adapt_beta', 'adapt_beta'), + ('adapt_tau', 'adapt_tau'), + ('cm', 'C_m', 1000.0), # nF -> pF + ('c_reg', 'c_reg'), + ('v_rest', 'E_L'), + ('f_target', 'f_target'), + ('gamma', 'gamma'), + ('i_offset', 'I_e', 1000.0), # nA -> pA + ('reg_spike_arr', 'regular_spike_arrival'), + ('surrogate_gradient_function', 'surrogate_gradient_function'), + ('tau_refrac', 't_ref'), + ('tau_m', 'tau_m'), + ('v_min', 'V_min'), + ('v_thresh', 'V_th'), + ) + variable_map = {'v': 'V_m', 'learning_signal': 'learning_signal', 'surrogate_gradient': 'surrogate_gradient'} + scale_factors = {'v': 1, 'learning_signal': 0.001, 'surrogate_gradient': 1} + nest_name = {"on_grid": "eprop_iaf_bsshslm_2020", + "off_grid": "eprop_iaf_bsshslm_2020"} + standard_receptor_type = True + + class Izhikevich(cells.Izhikevich): __doc__ = cells.Izhikevich.__doc__ diff --git a/pyNN/standardmodels/cells.py b/pyNN/standardmodels/cells.py index 2b34fdbf..a901bc90 100644 --- a/pyNN/standardmodels/cells.py +++ b/pyNN/standardmodels/cells.py @@ -684,6 +684,7 @@ def computed_parameters_include(self, parameter_names): for psr in self.post_synaptic_receptors.values()]) ) + class IF_eprop_adaptive(StandardCellType): """ Implementation of a leaky integrate-and-fire neuron model with delta-shaped @@ -737,6 +738,54 @@ class IF_eprop_adaptive(StandardCellType): } +class IF_eprop(StandardCellType): + """ + Implementation of a leaky integrate-and-fire neuron model with delta-shaped + postsynaptic currents used for eligibility propagation (e-prop) plasticity. + + Bellec G, Scherr F, Subramoney F, Hajek E, Salaj D, Legenstein R, Maass W (2020). + A solution to the learning dilemma for recurrent networks of spiking neurons. + Nature Communications, 11:3625. https://doi.org/10.1038/s41467-020-17236-y + """ + + default_parameters = { + 'cm': 0.250, # Membrane capacitance in nF + 'c_reg': 0.0, # Regularization factor + 'v_rest': -70.0, # Resting membrane potential in mV + 'f_target': 10.0, # Target firing rate of regularization factor in Hz + 'gamma': 0.3, # Scaling of surrogate gradient + 'i_offset': 0.0, # Offset current in nA + 'reg_spike_arr': True, # Regularize spike arrival times + 'surrogate_gradient_function': 'piecewise_linear', # Surrogate gradient function + 'tau_refrac': 2.0, # Refractory period in ms + 'tau_m': 10.0, # Membrane time constant in ms + 'v_min': -1.79e308, # Minimum membrane potential in mV + 'v_thresh': -55.0, # Spike threshold in mV + } + + recordable = ['v', 'spikes', 'learning_signal', 'surrogate_gradient'] + + default_initial_values = { + 'adaptation': 0.0, # Adaptation variable + 'learning_signal': 0.0, # Learning signal + 'surrogate_gradient': 0.0, # Surrogate gradient + 'v': -70.0, # Membrane potential + } + + units = { + 'cm': 'nF', + 'v_rest': 'mV', + 'f_target': 'Hz', + 'i_offset': 'nA', + 't_ref': 'ms', + 'tau_m': 'ms', + 'v_min': 'mV', + 'v_thresh': 'mV', + 'v': 'mV', + 'learning_signal': 'nA', + } + + class Izhikevich(StandardCellType): """ Izhikevich spiking model with a quadratic non-linearity according to: From 6663435be4511579aab46f1a1861b9af772c863f Mon Sep 17 00:00:00 2001 From: Harsh Khilawala Date: Wed, 24 Jul 2024 18:21:33 -0400 Subject: [PATCH 3/3] add eprop-iaf-readout NEST model --- pyNN/nest/standardmodels/cells.py | 23 +++++++++++++-- pyNN/standardmodels/cells.py | 47 ++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/pyNN/nest/standardmodels/cells.py b/pyNN/nest/standardmodels/cells.py index 13f9e68c..68f09aa5 100644 --- a/pyNN/nest/standardmodels/cells.py +++ b/pyNN/nest/standardmodels/cells.py @@ -424,13 +424,11 @@ class IF_eprop_adaptive(cells.IF_eprop_adaptive): standard_receptor_type = True -class IF_eprop(cells.IF_eprop_adaptive): +class IF_eprop(cells.IF_eprop): __doc__ = cells.IF_eprop.__doc__ translations = build_translations( - ('adapt_beta', 'adapt_beta'), - ('adapt_tau', 'adapt_tau'), ('cm', 'C_m', 1000.0), # nF -> pF ('c_reg', 'c_reg'), ('v_rest', 'E_L'), @@ -451,6 +449,25 @@ class IF_eprop(cells.IF_eprop_adaptive): standard_receptor_type = True +class IF_eprop_readout(cells.IF_eprop_readout): + + __doc__ = cells.IF_eprop_readout.__doc__ + + translations = build_translations( + ('cm', 'C_m', 1000.0), # nF -> pF + ('v_rest', 'E_L'), + ('i_offset', 'I_e', 1000.0), # nA -> pA + ('reg_spike_arr', 'regular_spike_arrival'), + ('tau_m', 'tau_m'), + ('v_min', 'V_min'), + ) + variable_map = {'v': 'V_m', 'error signal': 'error signal', 'readout_signal': 'readout_signal', 'readout_signal_unnorm': 'readout_signal_unnorm', 'target_signal': 'target_signal' } + scale_factors = {'v': 1, 'error signal': 1, 'readout_signal': 1, 'readout_signal_unnorm': 1, 'target_signal': 1} + nest_name = {"on_grid": "eprop_iaf_readout_bsshslm_2020", + "off_grid": "eprop_iaf_readout_bsshslm_2020"} + standard_receptor_type = True + + class Izhikevich(cells.Izhikevich): __doc__ = cells.Izhikevich.__doc__ diff --git a/pyNN/standardmodels/cells.py b/pyNN/standardmodels/cells.py index a901bc90..2eab9b2b 100644 --- a/pyNN/standardmodels/cells.py +++ b/pyNN/standardmodels/cells.py @@ -766,7 +766,6 @@ class IF_eprop(StandardCellType): recordable = ['v', 'spikes', 'learning_signal', 'surrogate_gradient'] default_initial_values = { - 'adaptation': 0.0, # Adaptation variable 'learning_signal': 0.0, # Learning signal 'surrogate_gradient': 0.0, # Surrogate gradient 'v': -70.0, # Membrane potential @@ -786,6 +785,52 @@ class IF_eprop(StandardCellType): } +class IF_eprop_readout(StandardCellType): + """ + Implementation of a integrate-and-fire neuron model with delta-shaped postsynaptic currents + used as readout neuron for eligibility propagation (e-prop) plasticity. + + Bellec G, Scherr F, Subramoney F, Hajek E, Salaj D, Legenstein R, Maass W (2020). + A solution to the learning dilemma for recurrent networks of spiking neurons. + Nature Communications, 11:3625. https://doi.org/10.1038/s41467-020-17236-y + """ + + default_parameters = { + 'cm': 0.250, # Membrane capacitance in nF + 'v_rest': -70.0, # Resting membrane potential in mV + 'i_offset': 0.0, # Offset current in nA + 'loss': 'mean_squared_error', # Loss function + 'reg_spike_arr': True, # Regularize spike arrival times + 'surrogate_gradient_function': 'piecewise_linear', # Surrogate gradient function + 'tau_m': 10.0, # Membrane time constant in ms + 'v_min': -1.79e308, # Minimum membrane potential in mV + } + + recordable = ['v', 'spikes', 'error_signal', 'readout_signal', 'readout_signal_unnorm', 'target_signal'] + + default_initial_values = { + 'error_signal': 0.0, # Error signal + 'readout_signal': 0.0, # Readout signal + 'readout_signal_unnorm': 0.0, # Unnormalized readout signal + 'target_signal': 0.0, # Target signal + 'v': -70.0, # Membrane potential + } + + units = { + 'cm': 'nF', + 'v_rest': 'mV', + 'i_offset': 'nA', + 'tau_m': 'ms', + 'v_min': 'mV', + 'v_thresh': 'mV', + 'v': 'mV', + 'error_signal': 'mV', + 'readout_signal': 'mV', + 'readout_signal_unnorm': 'mV', + 'target_signal': 'mV', + } + + class Izhikevich(StandardCellType): """ Izhikevich spiking model with a quadratic non-linearity according to: