22.02.2024 Views

Daniel Voigt Godoy - Deep Learning with PyTorch Step-by-Step A Beginner’s Guide-leanpub

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Transfer Learning in Practice

In Chapter 6, we created our own model to classify images in the Rock Paper Scissors

dataset. We’ll use the same dataset here, but, instead of creating another model,

we’ll take AlexNet for a spin!

It all starts with loading a pre-trained model, which can be easily done using

Torchvision’s library of models. There, we find AlexNet, a PyTorch model that

implements the architecture designed by Alex Krizhevsky et al., and alexnet, a

helper function that creates an instance of AlexNet and, optionally, downloads and

loads its pre-trained weights.

Pre-Trained Model

We’ll start by creating an instance of AlexNet without loading its pre-trained

weights just yet:

Loading AlexNet Architecture

1 alex = alexnet(pretrained=False)

2 print(alex)

Transfer Learning in Practice | 505

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!