AttributeError: module ‘torchtext.data’ has no attribute ‘Field’

From TorchText 0.9.0 Release Notes

torchtext.data.Field -> torchtext.legacy.data.Field
This means, all features are still available, but within torchtext.legacy instead of torchtext.

torchtext.data.Field has been moved to torchtext.legacy.data.Field

And the imports would change this way:

from torchtext.legacy import data

Leave a Comment