torchtext.functional¶
to_tensor¶
-
torchtext.functional.
to_tensor
(input: Any, padding_value: Optional[int] = None, dtype: torch.dtype = torch.int64) → torch.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
: