@@ -56,7 +56,7 @@ class EventSTDPSynapse(DenseSynapse): # event-driven, post-synaptic STDP
5656
5757 # Define Functions
5858 def __init__ (self , name , shape , eta , lmbda = 0.01 , A_plus = 1. , A_minus = 1. ,
59- presyn_win_len = 1 . , w_bound = 1. , weight_init = None , resist_scale = 1. ,
59+ presyn_win_len = 2 . , w_bound = 1. , weight_init = None , resist_scale = 1. ,
6060 p_conn = 1. , batch_size = 1 , ** kwargs ):
6161 super ().__init__ (name , shape , weight_init , None , resist_scale , p_conn ,
6262 batch_size = batch_size , ** kwargs )
@@ -65,6 +65,7 @@ def __init__(self, name, shape, eta, lmbda=0.01, A_plus=1., A_minus=1.,
6565 self .eta = eta ## global learning rate governing plasticity
6666 self .lmbda = lmbda ## controls scaling of STDP rule
6767 self .presyn_win_len = presyn_win_len
68+ assert self .presyn_win_len >= 0. ## pre-synaptic window must be non-negative
6869 self .Aplus = A_plus
6970 self .Aminus = A_minus
7071 self .Rscale = resist_scale ## post-transformation scale factor
@@ -82,10 +83,13 @@ def __init__(self, name, shape, eta, lmbda=0.01, A_plus=1., A_minus=1.,
8283 def _compute_update (t , lmbda , presyn_win_len , Aminus , Aplus , w_bound , pre_tols ,
8384 postSpike , weights ):
8485 ## check if a spike occurred in window of (t - presyn_win_len, t]
85- m = (pre_tols > 0. ) * 1. ## ignore default value of tols = 0 ms
86- lbound = ((t - presyn_win_len ) < pre_tols ) * 1.
87- rbound = (pre_tols <= t ) * 1.
88- preSpike = lbound * rbound * m
86+ m = (pre_tols > 0. ) * 1. ## ignore default value of tols = 0 ms
87+ if presyn_win_len > 0. :
88+ lbound = ((t - presyn_win_len ) < pre_tols ) * 1.
89+ preSpike = lbound * m
90+ else :
91+ check_spike = (pre_tols == t ) * 1.
92+ preSpike = check_spike * m
8993 ## this implements a generalization of the rule in eqn 18 of the paper
9094 pos_shift = w_bound - (weights * (1. + lmbda ))
9195 pos_shift = pos_shift * Aplus
0 commit comments