Shortcuts

Function torch::nn::utils::rnn::pack_sequence

Function Documentation

inline PackedSequence torch::nn::utils::rnn::pack_sequence(ArrayRef<Tensor> sequences, bool enforce_sorted = true)

Packs a list of variable length Tensors.

sequences should be a list of Tensors of size L x *, where L is the length of a sequence and * is any number of trailing dimensions, including zero.

For unsorted sequences, use enforce_sorted = false. If enforce_sorted is true, the sequences should be sorted in the order of decreasing length.

Arguments: sequences (torch::ArrayRef<Tensor>): A list of sequences of decreasing length. enforce_sorted (bool, optional): if true, checks that the input contains sequences sorted by length in a decreasing order. If false, this condition is not checked. Default: true.

Returns: a PackedSequence object

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources