Chapter 15. Application Architectures Deep Dive

We are now in the exciting position that we can fully understand the architectures that we have been using for our state-of-the-art models for computer vision, natural language processing, and tabular analysis. In this chapter, we’re going to fill in all the missing details on how fastai’s application models work and show you how to build them.

We will also go back to the custom data preprocessing pipeline we saw in Chapter 11 for Siamese networks and show you how to use the components in the fastai library to build custom pretrained models for new tasks.

We’ll start with computer vision.

Computer Vision

For computer vision applications, we use the functions cnn_learner and unet_learner to build our models, depending on the task. In this section, we’ll explore how to build the Learner objects we used in Parts I and II of this book.

cnn_learner

Let’s take a look at what happens when we use the cnn_learner function. We begin by passing this function an architecture to use for the body of the network. Most of the time, we use a ResNet, which you already know how to create, so we don’t need to delve into that any further. Pretrained weights are downloaded as required and loaded into the ResNet.

Then, for transfer learning, the network needs to be cut. This refers to slicing off the final layer, which is responsible only for ImageNet-specific categorization. In fact, we do not slice off only this layer, but everything from the adaptive ...

Get Deep Learning for Coders with fastai and PyTorch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.