def pad_packed_sequence(input, *args, **kwargs): r"""Pads a packed batch of variable length sequences. It is an inverse operation to :func:`pack_padded_sequence`. The returned Variable's data will be of size TxBx*, where T is the length of the longest sequence and B is the batch size. If ``batch_first`` is True, the data will be transposed into BxTx* format. Batch elements will be ordered decreasingly by their length. Arguments: sequence (PackedSequence): batch to pad batch_first (bool, optional): if ``True``, the output will be in BxTx* format. padding_value (float, optional): values for padded elements. Returns: Tuple of Variable containing the padded sequence, and Variable containing the list of lengths of each sequence in the batch. """ import torch if torch._C._jit_is_tracing(input.data): from torch.onnx import symbolic_override return symbolic_override(_symbolic_pad_packed_sequence)(_pad_packed_sequence)(input, *args, **kwargs) else: return _pad_packed_sequence(input, *args, **kwargs)
def pad_packed_sequence(input, *args, **kwargs): r"""Pads a packed batch of variable length sequences. It is an inverse operation to :func:`pack_padded_sequence`. The returned Variable's data will be of size TxBx*, where T is the length of the longest sequence and B is the batch size. If ``batch_first`` is True, the data will be transposed into BxTx* format. Batch elements will be ordered decreasingly by their length. Arguments: sequence (PackedSequence): batch to pad batch_first (bool, optional): if ``True``, the output will be in BxTx* format. padding_value (float, optional): values for padded elements. Returns: Tuple of Variable containing the padded sequence, and Variable containing the list of lengths of each sequence in the batch. """ import torch if torch._C._jit_is_tracing(input.data): from torch.onnx import symbolic_override return symbolic_override(_symbolic_pad_packed_sequence)( _pad_packed_sequence)(input, *args, **kwargs) else: return _pad_packed_sequence(input, *args, **kwargs)
def pack_padded_sequence(input, *args, **kwargs): r"""Packs a Variable containing padded sequences of variable length. Input can be of size ``TxBx*`` where T is the length of the longest sequence (equal to ``lengths[0]``), B is the batch size, and * is any number of dimensions (including 0). If ``batch_first`` is True ``BxTx*`` inputs are expected. The sequences should be sorted by length in a decreasing order, i.e. ``input[:,0]`` should be the longest sequence, and ``input[:,B-1]`` the shortest one. Note: This function accept any input that has at least two dimensions. You can apply it to pack the labels, and use the output of the RNN with them to compute the loss directly. A Variable can be retrieved from a :class:`PackedSequence` object by accessing its ``.data`` attribute. Arguments: input (Variable): padded batch of variable length sequences. lengths (Variable): list of sequences lengths of each batch element. batch_first (bool, optional): if ``True``, the input is expected in BxTx* format. Returns: a :class:`PackedSequence` object """ import torch if torch._C._jit_is_tracing(input): from torch.onnx import symbolic_override return symbolic_override(_symbolic_pack_padded_sequence)(_pack_padded_sequence)(input, *args, **kwargs) else: return _pack_padded_sequence(input, *args, **kwargs)
def pack_padded_sequence(input, *args, **kwargs): r"""Packs a Variable containing padded sequences of variable length. Input can be of size ``TxBx*`` where T is the length of the longest sequence (equal to ``lengths[0]``), B is the batch size, and * is any number of dimensions (including 0). If ``batch_first`` is True ``BxTx*`` inputs are expected. The sequences should be sorted by length in a decreasing order, i.e. ``input[:,0]`` should be the longest sequence, and ``input[:,B-1]`` the shortest one. Note: This function accept any input that has at least two dimensions. You can apply it to pack the labels, and use the output of the RNN with them to compute the loss directly. A Variable can be retrieved from a :class:`PackedSequence` object by accessing its ``.data`` attribute. Arguments: input (Variable): padded batch of variable length sequences. lengths (Variable): list of sequences lengths of each batch element. batch_first (bool, optional): if ``True``, the input is expected in BxTx* format. Returns: a :class:`PackedSequence` object """ import torch if torch._C._jit_is_tracing(input): from torch.onnx import symbolic_override return symbolic_override(_symbolic_pack_padded_sequence)( _pack_padded_sequence)(input, *args, **kwargs) else: return _pack_padded_sequence(input, *args, **kwargs)