Skip to content

Commit

Permalink
In pyrenn.py in the RTRL function:
Browse files Browse the repository at this point in the history
the sensitivity Matrix S is reseted every time
in dA_dw (derivative of layer outputs a with respect to weight vector w) entries older than q-max_delay are deleted

As suggested by jjboltz1234 here #2 (comment):
  • Loading branch information
yabata committed Nov 3, 2016
1 parent 59179f5 commit dbdf1fe
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python/pyrenn.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ def RTRL(net,data):
inputs = net['nn'][0] #number of inputs
outputs = net['nn'][-1] #number of outputs
layers = net['layers'] #structure of the NN
max_delay = net['dmax'] # Maximum delay in the NN
U = net['U'] #set of input layers (input layers or layers with internal delay>0 )
X = net['X'] #set of output layers (output of layer is used for cost function calculation
# or is added to the input layer with delay>1)
Expand Down Expand Up @@ -492,6 +493,17 @@ def RTRL(net,data):
# Jacobian Matrix
J[range(((q-q0)-1)*outputs,(q-q0)*outputs),:] = -dA_dw[q,M]

# Delete entries older than q-max_delay in dA_dw
if q > max_delay:
new_dA_dw = dict(dA_dw)
for key in dA_dw.keys():
if key[0] == q-max_delay:
del new_dA_dw[key]
dA_dw = new_dA_dw

# Reset S
S = {}

return J,E,e

def BPTT(net,data):
Expand Down

0 comments on commit dbdf1fe

Please sign in to comment.