0

I am trying to define a vocabulary with PyTorch to later input my dataset into a Neural Network. This would be the first step to create a dataset.

This is the code I am using:

text_field = torchtext.data.Field(tokenize="spacy")
text_field.build_vocab(train_data.Text, min_freq=3)

By running the code, I get the following error: "module 'torchtext.data' has no attribute 'Field'" I already looked at solutions where they suggest to use "torchtext.legacy.data.Field" instead, but nothing seems to work. I am using Python 3.10.1 and torchtext 0.15.1. Does anyone knows how to solve this issue?

1
  • The question seems to be duplicated with this one
    – Meti
    Commented Apr 30, 2023 at 18:15

1 Answer 1

0

i am afraid you have to downgrade pytorch and torchtext versions, that's what i did in order to work with data.field

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.