Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

2.1K
Views
AttributeError: el módulo 'torchtext.data' no tiene el atributo 'Field'

Quiero ejecutar un proyecto de git con pytorch y torchtext, pero cuando lo ejecuto, aparece un error:

 File "main.py", line 60, in <module> main() File "main.py", line 50, in main train_iters, dev_iters, test_iters, vocab = load_dataset(config) File "/home/esmailza/style transfer/style-transformer/data.py", line 23, in load_dataset TEXT = data.Field(batch_first=True, eos_token='<eos>') AttributeError: module 'torchtext.data' has no attribute 'Field'

versión antorcha = 1.8.0 versión texto antorcha = 0.9

 def load_dataset(config, train_pos='train.pos', train_neg='train.neg', dev_pos='dev.pos', dev_neg='dev.neg', test_pos='test.pos', test_neg='test.neg'): root = config.data_path TEXT = data.Field(batch_first=True, eos_token='<eos>') dataset_fn = lambda name: data.TabularDataset( path=root + name, format='tsv', fields=[('text', TEXT)] )
over 4 years ago · Hanz Gallego
2 answers
Answer question

0

Gracias, @Rishabh Kumar responde también, ¡esto funciona para mí!

De las notas de la versión de TorchText 0.9.0

Basado en la versión v0.9 https://github.com/pytorch/text/releases/tag/v0.9.0-rc5

Los usuarios actuales del código heredado experimentarán la ruptura de BC ya que hemos retirado el código heredado (#1172, #1181, #1183). Los componentes heredados se colocan en la carpeta torchtext.legacy.data de la siguiente manera:

 torchtext.data.Pipeline -> torchtext.legacy.data.Pipeline torchtext.data.Batch -> torchtext.legacy.data.Batch torchtext.data.Example -> torchtext.legacy.data.Example torchtext.data.Field -> torchtext.legacy.data.Field torchtext.data.Iterator -> torchtext.legacy.data.Iterator torchtext.data.Dataset -> torchtext.legacy.data.Dataset

Esto significa que todas las funciones aún están disponibles, pero dentro de torchtext.legacy en lugar de torchtext.

over 4 years ago · Hanz Gallego Report

0

De las notas de la versión de TorchText 0.9.0

torchtext.data.Field -> torchtext.legacy.data.Field
Esto significa que todas las funciones aún están disponibles, pero dentro de torchtext.legacy en lugar de torchtext .

torchtext.data.Field se ha movido a torchtext.legacy.data.Field

Y las importaciones cambiarían de esta manera:

 from torchtext.legacy import data
over 4 years ago · Hanz Gallego Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!