How are filled sequences defined as packed sequences handled by RNNs in pytorch?

In pytorch we can give a packed sequence as an input to RNN. From an official document, an RNN entry may be as follows.

input (seq_len, batch, input_size) : a tensor containing functions of the input sequence. Input can also be a sequence of packed variable lengths.

Example

packed = torch.nn.utils.rnn.pack_padded_sequence(embedded, input_lengths)
outputs, hidden = self.rnn(packed, hidden)
outputs, output_lengths = torch.nn.utils.rnn.pad_packed_sequence(outputs)

Here embeddedis a built-in representation of batch input.

My question is: how is the calculation performed for packed sequences in RNN? How are hidden states calculated for populated sequences in a batch view via a packed view?

+6
1

matthew_zeng : , .

0

All Articles