Skip to content

AttributeError: '_MultiProcessingDataLoaderIter' object has no attribute 'next' #3

@DavidCarlyn

Description

@DavidCarlyn

I get the following error when running python main_recon.py --num_classes 10 --num_cpt 20 --lr 0.001 --epoch 50 --lr_drop 30:

AttributeError: '_MultiProcessingDataLoaderIter' object has no attribute 'next'

Pytorch versions: torch==2.0.1 and torchvision==0.15.2

Error happens in utils/engine_recon.py on line 80 and in vis_recon.py on line 37. I used the solution mentioned in https://stackoverflow.com/questions/74289077/attributeerror-multiprocessingdataloaderiter-object-has-no-attribute-next to fix it.

There may be other areas of the codebase that also use this syntax.

Current line:

data, label = iter(loader).next()

Proposed line change:

data, label = next(iter(loader))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions