Skip to content

Instantly share code, notes, and snippets.

@ArnoutDevos
Created December 31, 2017 15:53
Show Gist options
  • Save ArnoutDevos/29f6afb5b6da3091a7c4696e31f85004 to your computer and use it in GitHub Desktop.
Save ArnoutDevos/29f6afb5b6da3091a7c4696e31f85004 to your computer and use it in GitHub Desktop.
def step_backward(self, dnext_h, meta):
x, prev_h, next_h = meta
dtanh = dnext_h*(1.0-next_h**2)
dx = dtanh.dot(self.params[self.wx_name].T)
dprev_h = dtanh.dot(self.params[self.wh_name].T)
dWx = x.T.dot(dtanh)
dWh = prev_h.T.dot(dtanh)
db = np.sum(dtanh,axis=0)
return dx, dprev_h, dWx, dWh, db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment