dvgodoy / PyTorchStepByStep

Official repository of my book: "Deep Learning with PyTorch Step-by-Step: A Beginner's Guide"
https://pytorchstepbystep.com
MIT License
866 stars 332 forks source link

Changed next() approach to iterate DataLoader #29

Closed scmanjarrez closed 1 year ago

scmanjarrez commented 1 year ago

First of all, thank you for your amazing book (and repository). Lot of concepts are extremely well explained and easy to understand.

Previous chapter used next(iter(DL)), however, chapter 5 uses iter(DL).next() which throws the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[149], line 1
----> 1 images_batch, labels_batch = iter(val_loader).next()
      2 logits = sbs_cnn1.predict(images_batch)

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

I don't know if that function was implemented in previous PyTorch versions, however with PyTorch 1.13, it doesn't work anymore.

Note: Python 3.8.10, jupyterlab 3.5.0

dvgodoy commented 1 year ago

Hi @scmanjarrez

Thank you for your kind words, and for spotting and fixing this issue :-)

Best, Daniel