Skip to content

Spring 2022 GANs '_SingleProcessDataLoaderIter' object has no attribute 'next' #287

Description

@caojoshua

When extracting and showing MNIST, we get

'_SingleProcessDataLoaderIter' object has no attribute 'next'

According to this stackoverflow post, iter(...).next() is deprecated starting from pytorch 1.13, released in October 2022. I can fix this with this change:

     "    sampler=ChunkSampler(NUM_VAL, NUM_TRAIN)\n",
     ")\n",
     "\n",
-    "imgs = loader_train.__iter__().next()[0].view(batch_size, 784).numpy().squeeze()\n",
+    "i = loader_train.__iter__()\n",
+    "imgs = next(i)[0].view(batch_size, 784).numpy().squeeze()\n",
     "show_images(imgs)"
    ]
   },

(diff looks kinda weird for jupyter notebooks, but I think it gets the point across.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions