Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flowtron.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def run_padded_sequence(self, sorted_idx, unsort_idx, lens, padded_data, recurre
# sort the data by decreasing length using provided index
# we assume batch index is in dim=1
padded_data = padded_data[:, sorted_idx]
padded_data = nn.utils.rnn.pack_padded_sequence(padded_data, lens)
padded_data = nn.utils.rnn.pack_padded_sequence(padded_data, lens.cpu())
hidden_vectors = recurrent_model(padded_data)[0]
hidden_vectors, _ = nn.utils.rnn.pad_packed_sequence(hidden_vectors)
# unsort the results at dim=1 and return
Expand Down Expand Up @@ -320,7 +320,7 @@ def forward(self, x, in_lens):
for conv in self.convolutions:
x = F.dropout(F.relu(conv(x)), 0.5, self.training)
x = x.transpose(1, 2)
x = nn.utils.rnn.pack_padded_sequence(x, in_lens, batch_first=True)
x = nn.utils.rnn.pack_padded_sequence(x, in_lens.cpu(), batch_first=True)

self.lstm.flatten_parameters()
outputs, _ = self.lstm(x)
Expand Down Expand Up @@ -448,7 +448,7 @@ def run_padded_sequence(self, sorted_idx, unsort_idx, lens, padded_data,
# sort the data by decreasing length using provided index
# we assume batch index is in dim=1
padded_data = padded_data[:, sorted_idx]
padded_data = nn.utils.rnn.pack_padded_sequence(padded_data, lens)
padded_data = nn.utils.rnn.pack_padded_sequence(padded_data, lens.cpu())
hidden_vectors = recurrent_model(padded_data)[0]
hidden_vectors, _ = nn.utils.rnn.pad_packed_sequence(hidden_vectors)
# unsort the results at dim=1 and return
Expand Down