Last active
December 8, 2018 11:06
-
-
Save hadifar/84ceccccd656397a09fc458531f2a335 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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