Skip to content
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

add eprop-iaf-adapt NEST model #808

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions pyNN/nest/standardmodels/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,77 @@ class EIF_cond_exp_isfa_ista(cells.EIF_cond_exp_isfa_ista):
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 IF_eprop(cells.IF_eprop):

__doc__ = cells.IF_eprop.__doc__

translations = build_translations(
('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 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__

Expand Down
146 changes: 146 additions & 0 deletions pyNN/standardmodels/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,152 @@ def computed_parameters_include(self, parameter_names):
)


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 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 = {
'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 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:
Expand Down