SamLynnEvans / Transformer

Transformer seq2seq model, program that can build a language translator from parallel corpus
Apache License 2.0
1.35k stars 350 forks source link

AttributeError: module 'torchtext.data' has no attribute 'Iterator' #29

Open foreseez opened 3 years ago

foreseez commented 3 years ago

Traceback (most recent call last): File "train.py", line 5, in <module> from Process import * File "/Users/pycharm_pro/PyTorch_Learning/Transformer/Process.py", line 5, in <module> from Batch import MyIterator, batch_size_fn File "/Users/pycharm_pro/PyTorch_Learning/Transformer/Batch.py", line 35, in <module> class MyIterator(data.Iterator): AttributeError: module 'torchtext.data' has no attribute 'Iterator'

https://pytorch.org/text/stable/data_functional.html

image

i guess whether the torchtext.data's api has changed ,but i don't find right api

ithieund commented 3 years ago

The same for me :(

A-Kerim commented 3 years ago

You may try this : from torchtext.legacy import data instead of from torchtext import data.

ithieund commented 3 years ago

Thank you

On Wed, Apr 21, 2021 at 4:00 PM A-Kerim @.***> wrote:

You may try this : from torchtext.legacy import data instead of from torchtext import data.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SamLynnEvans/Transformer/issues/29#issuecomment-823901711, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAFS2ZTH3XW5DEKOYGAPT3TJ2H23ANCNFSM4ZGDCAKA .

-- Sent from my iPhone

robby927 commented 3 years ago

You can install a old torchtext version: pip install torchtext==0.6.0

pandya6988 commented 2 years ago

You may try this : from torchtext.legacy import data instead of from torchtext import data.

AttributeError: module 'torchtext' has no attribute 'legacy'

No one is maintaining torchtext anymore or what!!!

na018 commented 1 year ago

torchtext.legacy

Same problem for me. So I guess we need another Iterator.

CroceCanale commented 1 year ago

You can install a old torchtext version: pip install torchtext==0.6.0

That's helpful, thank you!