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 torch | |
import torch.nn as nn | |
from torch.autograd import Variable | |
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence | |
x = Variable(torch.randn(10, 20, 30)).cuda() | |
lens = range(10) | |
x = pack_padded_sequence(x, lens[::-1], batch_first=True) |