Skip to content

Instantly share code, notes, and snippets.

@hadifar
Last active December 8, 2018 11:06
Show Gist options
  • Select an option

  • Save hadifar/84ceccccd656397a09fc458531f2a335 to your computer and use it in GitHub Desktop.

Select an option

Save hadifar/84ceccccd656397a09fc458531f2a335 to your computer and use it in GitHub Desktop.
class SimpleRNN:
def __init__():
self.W_sh = np.zeros(shape=[rnn_size, rnn_size])
self.W_xh = np.zeros(shape=[word_vecotr_size, rnn_size])
self.s = np.zeros(shape=[rnn_size,1]
def step(self, x):
# update the state
self.s = np.tanh(np.dot(self.W_sh, self.s) + np.dot(self.W_xh, x))
# compute the output vector
y = softmax(self.s)
return y
rnn = SimpleRnn()
y = rnn.step(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment