Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
caojoshua opened this issue Feb 13, 2023 · 2 comments

Comments

@caojoshua
Copy link

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.)

@caojoshua
Copy link
Author

As a side note, I think the code should be directly in the repo, rather than stored in zip files. That way users can easily submit PRs to fix code.

@caojoshua
Copy link
Author

Same issue in Self Supervised Learning notebook in Data Augmentation blocks.

-    "    images, labels = dataiter.next()\n",
+    "    images, labels = next(dataiter)\n",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant