-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrl.py
More file actions
32 lines (20 loc) · 822 Bytes
/
rl.py
File metadata and controls
32 lines (20 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
########################################################## README ###########################################################
# This file implements STDP curve and weight update rule
##############################################################################################################################
import numpy as np
from matplotlib import pyplot as plt
from parameters import param as par
#STDP reinforcement learning curve
def rl(t):
if t>0:
return -par.A_plus*np.exp(-float(t)/par.tau_plus)
if t<=0:
return par.A_minus*np.exp(float(t)/par.tau_minus)
#STDP weight update rule
def update(w, del_w):
if del_w<0:
return w + par.sigma*del_w*(w-abs(par.w_min))*par.scale
elif del_w>0:
return w + par.sigma*del_w*(par.w_max-w)*par.scale
if __name__ == '__main__':
print(rl(-20)*par.sigma)