Created
August 7, 2018 20:12
-
-
Save llSourcell/8a8b5b593bdf0b77bed3ee33130256ca 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 NeuralAccumulatorCell(nn.Module): | |
| #PyTorch Code for the NAC! | |
| def __init__(self, in_dim, out_dim): | |
| super().__init__() | |
| self.in_dim = in_dim | |
| self.out_dim = out_dim | |
| self.W_hat = Parameter(torch.Tensor(out_dim, in_dim)) | |
| self.M_hat = Parameter(torch.Tensor(out_dim, in_dim)) | |
| self.W = Parameter(F.tanh(self.W_hat) * F.sigmoid(self.M_hat)) | |
| self.register_parameter('bias', None) | |
| init.kaiming_uniform_(self.W_hat, a=math.sqrt(5)) | |
| init.kaiming_uniform_(self.M_hat, a=math.sqrt(5)) | |
| def forward(self, input): | |
| return F.linear(input, self.W, self.bias) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment