norse.torch.functional.stdp module

class norse.torch.functional.stdp.STDPParameters(a_pre=tensor(1.), a_post=tensor(1.), tau_pre_inv=tensor(20.), tau_post_inv=tensor(20.), w_min=0.0, w_max=1.0, eta_plus=0.001, eta_minus=0.001, stdp_algorithm='additive', mu=0.0, hardbound=True, convolutional=False, stride=1, padding=0, dilation=1)[source]

Bases: object

STDP parameters. :type a_pre: Tensor :param a_pre: Contribution of presynaptic spikes to trace :type a_pre: torch.Tensor :type a_post: Tensor :param a_post: Contribution of postsynaptic spikes to trace :type a_post: torch.Tensor :type tau_pre_inv: Tensor :param tau_pre_inv: Inverse decay time constant of presynaptic spike trace in 1/s :type tau_pre_inv: torch.Tensor :type tau_post_inv: Tensor :param tau_post_inv: Inverse decay time constant of postsynaptic spike trace in 1/s :type tau_post_inv: torch.Tensor :type w_min: Tensor :param w_min: Lower bound on synaptic weights (should be < w_max) :type w_min: torch.Tensor :type w_max: Tensor :param w_max: Upper bound on synaptic weight (should be > w_min) :type w_max: torch.Tensor :type eta_plus: Tensor :param eta_plus: Learning rate for synaptic potentiation (0 < eta_plus << 1) :type eta_plus: torch.Tensor :type eta_minus: Tensor :param eta_minus: Learning rate for synaptic depression (0 < eta_minus << 1) :type eta_minus: torch.Tensor :type stdp_algorithm: str :param stdp_algorithm: Algorithm for STDP updates. Options in {“additive”,”additive_step”,”multiplicative_pow”,”multiplicative_relu”} :type stdp_algorithm: string :type mu: Tensor :param mu: Exponent for multiplicative STDP (0 <= mu <= 1) :type mu: torch.Tensor :type hardbound: bool :param hardbound: Impose hardbounds by clipping (recommended unles eta_* << 1) :type hardbound: boolean :type convolutional: bool :param convolutional: Convolutional weighting kernel :type convolutional: boolean :type stride: int :param stride: Stride for convolution :type stride: int :type padding: int :param padding: Padding for convolution :type padding: int :type dilation: int :param dilation: Dilation for convolution :type dilation: int

class norse.torch.functional.stdp.STDPState(t_pre, t_post)[source]

Bases: object

State of spike-timing-dependent plasticity (STDP). :type t_pre: Tensor :param t_pre: presynaptic spike trace :type t_pre: torch.Tensor :type t_post: Tensor :param t_post: postsynaptic spike trace :type t_post: torch.Tensor

decay(z_pre, z_post, tau_pre_inv, tau_post_inv, a_pre, a_post, dt=0.001)[source]

Decay function for STDP traces. :type z_pre: Tensor :param z_pre: presynaptic spikes :type z_pre: torch.Tensor :type z_post: Tensor :param z_post: postsynaptic spikes :type z_post: torch.Tensor :type tau_pre_inv: Tensor :param tau_pre_inv: inverse time-constant for the presynaptic trace :type tau_pre_inv: torch.Tensor :param tau_post: inverse time-constant for the postsynaptic trace :type tau_post: torch.Tensor :type a_pre: Tensor :param a_pre: presynaptic trace :type a_pre: torch.Tensor :type a_post: Tensor :param a_post: postsynaptic trace :type a_post: torch.Tensor :type dt: float :param dt: time-resolution :type dt: float

norse.torch.functional.stdp.stdp_step_conv2d(z_pre, z_post, w, state_stdp, p_stdp=<norse.torch.functional.stdp.STDPParameters object>, dt=0.001)[source]

STDP step for a conv2d LIF layer. Input:

z_pre (torch.tensor): Presynaptic activity z: {0,1} -> {no spike, spike} z_post (torch.tensor): Postsynaptic activity z: {0,1} -> {no spike, spike} w (torch.Tensor): Weight tensor connecting the pre- and postsynaptic layers state_stdp (STDPState): STDP state p_stdp (STDPParameters): Parameters of STDP dt (float): Time-resolution

Output:

w (torch.tensor): Updated synaptic weights state_stdp (STDPState): Updated STDP state

Return type

Tuple[Tensor, STDPState]

norse.torch.functional.stdp.stdp_step_linear(z_pre, z_post, w, state_stdp, p_stdp=<norse.torch.functional.stdp.STDPParameters object>, dt=0.001)[source]

STDP step for a FF LIF layer. Input:

z_pre (torch.Tensor): Presynaptic activity z: {0,1} -> {no spike, spike} z_post (torch.Tensor): Postsynaptic activity z: {0,1} -> {no spike, spike} w (torch.Tensor): Weight tensor connecting the pre- and postsynaptic layers state_stdp (STDPState): STDP state p_stdp (STDPParameters): Parameters of STDP dt (float): Time-resolution

Output:

w (torch.tensor): Updated synaptic weights state_stdp (STDPState): Updated STDP state

Return type

Tuple[Tensor, STDPState]