Skip to content

Instantly share code, notes, and snippets.

Nicolas ngarneau

Block or report user

Report or block ngarneau

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Tushar-N
Tushar-N / pad_packed_demo.py
Last active Nov 14, 2019
How to use pad_packed_sequence in pytorch
View pad_packed_demo.py
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
seqs = ['gigantic_string','tiny_str','medium_str']
# make <pad> idx 0
vocab = ['<pad>'] + sorted(set(''.join(seqs)))
# make model
You can’t perform that action at this time.