torchtext.functional¶
to_tensor¶
- torchtext.functional.to_tensor(input: Any, padding_value: Optional[int] = None, dtype: dtype = torch.int64) Tensor [source]¶
Convert input to torch tensor
- Parameters:
padding_value (Optional[int]) – Pad value to make each input in the batch of length equal to the longest sequence in the batch.
dtype (
torch.dtype
) –torch.dtype
of output tensorinput (Union[List[int], List[List[int]]]) – Sequence or batch of token ids
- Return type:
Tensor
- Tutorials using
to_tensor
: SST-2 Binary text classification with XLM-RoBERTa model
SST-2 Binary text classification with XLM-RoBERTa model