How to convert string to tensor having torchtext.data.Field created?

665 Views Asked by At

So I have a torchtext.data.Field with build_vocab done. I have trained my model on my dataset. How to use it to convert raw string into tensor for model to be able to do prediction?

1

There are 1 best solutions below

0
On

You can use Example with the Fields you used for training. Or create another dataset if you have more than one example to predict for, again with the same Fields. They keep all instructions of how to create a tensor, incl. the vocabulary.