liveBook · Manning

Target domain

As explained in Inside Deep Learning: Math, Algorithms, Models

The dataset or domain on which a pretrained model is adapted and evaluated in transfer learning.

A target domain is the new dataset or problem where a pretrained model is adapted. In the ResNet example, cats-versus-dogs classification is the target domain, replacing ImageNet's 1,000-class output with two outputs. section 13.2

Use the target domain to guide transfer-learning changes:

  • Replace the pretrained network's final classifier so its outputs match the target classes. section 13.2
  • Prefer a source dataset that is larger and sufficiently relevant, because reusable learned patterns can reduce what must be learned from scratch. section 13.2.1

Cats-versus-dogs adaptation

Instantiate ResNet-18, retain its learned feature layers, and replace its 1,000-output classifier with nn.Linear(model.fc.in_features, 2). Train the resulting model with CrossEntropyLoss. section 13.2

Figure 13.3 The left side shows a summary of ResNet. We want to alter it to look like the right side, where only the last nn.Linear layer has been changed. The input to each nn.Linear layer is 512 because the final convolutional layer has C = 512 channels, and using adaptive average pooling down to just 1 × 1 means there are only 512 values in the output, regardless of the size of the original image.

Compare the original ResNet classifier with the adapted two-output classifier and see why adaptive pooling preserves a fixed feature width. section 13.2

How Inside Deep Learning: Math, Algorithms, Models covers it

How deep it goes
Defines the source-target relationship and shows classifier replacement, but defers broader adaptation procedures.
Examples
Uses cats-versus-dogs classification as the target problem and ImageNet as the source domain.
What it assumes
Assumes familiarity with datasets, classification outputs, pretrained networks, and PyTorch modules.
What you can do after
Apply it via PyTorch by replacing a pretrained model's final layer and training it for target classes.
How it connects
Connects target domains with transfer learning, source domains, pretrained models, CNNs, and classification.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Inside Deep Learning: Math, Algorithms, Models. The section links point to the parts of the book it draws on.