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.

need to reattach the "top" layer:

Replacing Top Layer

1 model.fc = top_model

2 sbs_temp = StepByStep(model, None, None)

We can still create a separate instance of StepByStep for the full model so as to be

able to call its predict() or correct() methods (in this case, both loss function and

optimizers are set to None since we won’t be training the model anymore):

Evaluation

StepByStep.loader_apply(val_loader, sbs_temp.correct)

Output

tensor([[ 98, 124],

[124, 124],

[104, 124]])

We got the same results, as expected.

Recap

In this chapter, we’ve learned about the ImageNet Large Scale Visual Recognition

Challenge (ILSVRC) and the many model architectures developed to tackle it

(AlexNet, VGG, Inception, and ResNet). We used their pre-trained weights to

perform transfer learning and either fine-tune or extract features for our own

classification task. Moreover, we took a quick tour of the inner workings of many

architectural elements built into these models. This is what we’ve covered:

• learning about transfer learning

• learning about ImageNet, ILSVRC, and the most popular architectures

developed to tackle it

• comparing the size, speed, and performance of these architectures

• loading the AlexNet model

• loading the model’s pre-trained weights

558 | Chapter 7: Transfer Learning

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

Saved successfully!

Ooh no, something went wrong!