Skip to content

Instantly share code, notes, and snippets.

@khanhnamle1994
Created May 21, 2018 03:34
Show Gist options
  • Save khanhnamle1994/fd0b0169bd5b55cbe029ac21022fcec5 to your computer and use it in GitHub Desktop.
Save khanhnamle1994/fd0b0169bd5b55cbe029ac21022fcec5 to your computer and use it in GitHub Desktop.
Initializing RNN Model with random weights
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