Created
May 20, 2022 14:44
-
-
Save blythed/58de8f90516cdcdc550bba2305a0913e to your computer and use it in GitHub Desktop.
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
import padl | |
import torch | |
hidden_size = padl.param('hidden_size', 512) | |
input_size = padl.param('input_size', 64) | |
n_tokens = padl.param('n_tokens', 16) | |
nn = padl.transform(torch.nn) | |
@padl.transform | |
class HiddenState(torch.nn.Module): | |
def __init__(self, layer): | |
super().__init__() | |
self.layer = layer | |
def forward(self, x): | |
return self.layer(x)[0] | |
rnn_layer = nn.GRU(input_size, hidden_size, 1) | |
_pd_main = ( | |
nn.Embedding(n_tokens, input_size) | |
>> HiddenState(rnn_layer) | |
>> nn.Linear(hidden_size, 1) | |
>> nn.Sigmoid() | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment