Skip to content

Instantly share code, notes, and snippets.

@braingineer
Created October 8, 2018 15:45
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 braingineer/1d7baecf2c99013d88d4d1db77449aec to your computer and use it in GitHub Desktop.
Save braingineer/1d7baecf2c99013d88d4d1db77449aec to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@braingineer
Copy link
Author

x_embedded = embedding(batch_dict[...])

  1. it should be (batch, feat, seq)
  2. conv1 = nn.Conv1d(
    in_channels=feat,
    out_channels=??,
    kernel_size=??,
    stride=1,
    padding=0
    )

@braingineer
Copy link
Author

batch_gen = generate_batches(train_dataset, batch_size=8)
batch_dict = next(batch_gen)

embeddings = nn.Embedding(num_embeddings=len(vectorizer.surname_vocab), 
                          embedding_dim=hyperparams.embedding_dim, 
                          padding_idx=0)

x_embedded = embeddings(batch_dict['x_surnames'])
x_embedded.shape

x_embedded_fixed = x_embedded.permute(0, 2, 1)
x_embedded_fixed.shape

conv1 = nn.Conv1d(in_channels=hyperparams.embedding_dim,
                  out_channels=16, 
                  kernel_size=3)
conv1(x_embedded_fixed).shape

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment