Transformer icon indicating copy to clipboard operation
Transformer copied to clipboard

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

Open foreseez opened this issue 3 years ago • 7 comments

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'

    • torch 1.8.0
  • torch-cluster 1.5.4
  • torch-geometric 1.5.0
  • torch-scatter 2.0.4
  • torch-sparse 0.6.1
  • torch-spline-conv 1.2.0
  • torchtext 0.9.0

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

foreseez avatar Mar 15 '21 08:03 foreseez

The same for me :(

ithieund avatar Apr 21 '21 08:04 ithieund

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

A-Kerim avatar Apr 21 '21 09:04 A-Kerim

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

ithieund avatar Apr 22 '21 01:04 ithieund

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

robby927 avatar Oct 20 '21 13:10 robby927

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!!!

pandya6988 avatar Oct 04 '22 00:10 pandya6988

torchtext.legacy

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

na018 avatar Dec 20 '22 09:12 na018

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

That's helpful, thank you!

CroceCanale avatar May 17 '23 08:05 CroceCanale