Skip to content

Instantly share code, notes, and snippets.

@Blaizzy
Last active September 25, 2019 19:44
Show Gist options
  • Select an option

  • Save Blaizzy/a39ba3aec8f17660af1c47d16abf83a1 to your computer and use it in GitHub Desktop.

Select an option

Save Blaizzy/a39ba3aec8f17660af1c47d16abf83a1 to your computer and use it in GitHub Desktop.
## Numpy implementation of GRU
# Params
ht = []
for t, xt in enumerate(train_data):
if t == 0: h.append(t)
if t >= 1:
ht_1 = ht[t-1]
zt = sigmoid(np.dot(xt, Wz) + np.dot(ht_1, Uz) + bz) # Update Gate Vector
rt = sigmoid(np.dot(xt, Wr)+ np.dot(ht_1, Ur) + br) # Forget/Reset Gate Vector
ht.append((1 - z) * ht_1 + z * np.tanh(np.dot(xt, Wh)
+ np.dot(r * ht_1, Uh) + bh)) # Output Vector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment