Created
August 19, 2018 02:47
-
-
Save omarsar/e2d38defaa99f97e0d7f87f9dcec2df5 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 SingleRNN(nn.Module): | |
def __init__(self, n_inputs, n_neurons): | |
super(SingleRNN, self).__init__() | |
self.Wx = torch.randn(n_inputs, n_neurons) # 4 X 1 | |
self.Wy = torch.randn(n_neurons, n_neurons) # 1 X 1 | |
self.b = torch.zeros(1, n_neurons) # 1 X 4 | |
def forward(self, X0, X1): | |
self.Y0 = torch.tanh(torch.mm(X0, self.Wx) + self.b) # 4 X 1 | |
self.Y1 = torch.tanh(torch.mm(self.Y0, self.Wy) + | |
torch.mm(X1, self.Wx) + self.b) # 4 X 1 | |
return self.Y0, self.Y1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment