Created
May 21, 2018 03:34
-
-
Save khanhnamle1994/fd0b0169bd5b55cbe029ac21022fcec5 to your computer and use it in GitHub Desktop.
Initializing RNN Model with random weights
This file contains 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 Model: | |
def __init__(self, word_dim, hidden_dim=100, bptt_truncate=4): | |
self.word_dim = word_dim | |
self.hidden_dim = hidden_dim | |
self.bptt_truncate = bptt_truncate | |
self.U = np.random.uniform(-np.sqrt(1. / word_dim), np.sqrt(1. / word_dim), (hidden_dim, word_dim)) | |
self.W = np.random.uniform(-np.sqrt(1. / hidden_dim), np.sqrt(1. / hidden_dim), (hidden_dim, hidden_dim)) | |
self.V = np.random.uniform(-np.sqrt(1. / hidden_dim), np.sqrt(1. / hidden_dim), (word_dim, hidden_dim)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment