Skip to content

Instantly share code, notes, and snippets.

@blythed
Last active April 28, 2022 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blythed/747dc3896f8b6cd16686e524c3f7ec74 to your computer and use it in GitHub Desktop.
Save blythed/747dc3896f8b6cd16686e524c3f7ec74 to your computer and use it in GitHub Desktop.
import padl
import torch
from padl import params
from my_codebase.pipelines import build_string_processor, build_preprocessor, build_model
from my_codebase.models import build_classifier
from my_codebase.transforms import Dictionary, build_dictionary
nn = padl.transform(torch.nn)
string_processor = build_string_processor()
words = padl.value(build_dictionary(string_processor, 'corpus.txt'))
dictionary = Dictionary(words)
preprocess = build_preprocessor(dictionary, string_processor)
rnn = torch.nn.GRU(
num_layers=1,
**params(
'rnn',
input_size=len(dictionary),
hidden_size=512,
),
)
layer = build_classifier(
rnn,
len(dictionary),
)
m = build_model(layer, preprocess)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment