dvgodoy / PyTorchStepByStep

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

Structure of torchvision.models has changed #37

Closed newyorker123 closed 11 months ago

newyorker123 commented 1 year ago

Hi,

I'm using torchvision 0.15.2. When I study chapter 7 transfer learning, I find that the structure of torchvision.models is changed and some code in the book now has problems.

For example, the _modelurls method is deprecated and can't be imported. In addition, alexnet(pretrained=False) gives warning. Now, one should use the Weight object, like resnet50(weights=ResNet50_Weights.IMAGENET1K_V1).

Will you update chapter 7 in the near future to reflect these new features?

Thank you very much.

dvgodoy commented 1 year ago

Hi @newyorker123 ,

You're absolutely right, the code was broken for torchvision 0.15.2.

I fixed the notebook, making changes to reflect torchvision's new approach to loading weights, and added a small section explaining the changes, right before loading alexnet. This should make it easier to follow along, even if the book itself still describes the old way.

Thank you for your feedback and for supporting my work :-)

Best, Daniel

newyorker123 commented 1 year ago

Hi @newyorker123 ,

You're absolutely right, the code was broken for torchvision 0.15.2.

I fixed the notebook, making changes to reflect torchvision's new approach to loading weights, and added a small section explaining the changes, right before loading alexnet. This should make it easier to follow along, even if the book itself still describes the old way.

Thank you for your feedback and for supporting my work :-)

Best, Daniel

Thank you so much!