question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
A-Kerimcommented, Apr 21, 2021

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

0reactions
na018commented, Dec 20, 2022

torchtext.legacy

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

module 'torchtext.data' has no attribute 'Iterator' #1275 - GitHub
Yes, torchtext.data indeed have no attribute 'Iterator' in the latest release (https://github.com/pytorch/text/blob/release/0.9/torchtext ...
Read more >
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, ...
Read more >
module torchtext.data has no attribute field ( Solved )
Module torchtext.data has no attribute field error occurs because of internal directory structure change in torchtext in 0.9.0 version.
Read more >
module 'torchtext.data' has no attribute 'field' - You.com
AttributeError : module 'torchtext.data' has no attribute 'Field' ·. · -> ·.legacy. ·. · This means, all features are still available, but within...
Read more >
module 'torchtext.data' has no attribute 'Iterator' - Bountysource
Questions and Help. Description. class MyIterator(data.Iterator): def create_batches(self): if self.train: def pool(d, random_shuffler):
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found