Data augmentation makes new training examples by changing existing ones. The useful changes preserve what the model must recognize while making the result harder to memorize. This increases a dataset’s effective size without collecting more samples—a practical way to encourage generalization when data is limited. section 14.6 section 5.5.3
The change must matter to the task. For a face-to-age model, changing a few corner pixels creates many nominally different images, but the model can simply ignore those pixels. A left-to-right mirror is more useful: it changes the face while preserving its age-related features. An upside-down face, by contrast, may be too unrealistic. Choose transformations with domain knowledge, not just a desire to produce more images. section 14.6 section 14.6.1
For a 3D CT nodule candidate, the available alterations are:
- Mirror the image along selected axes. section 14.6.1
- Shift it by a few voxels, scale it, or rotate it around the head-foot axis. section 14.6.1
- Add random noise to its values. section 14.6.1
Shift a CT candidate during training
Start with an identity transform, then assign a random offset on each of its three axes: transform_t = torch.eye(4) for i in range(3): random_float = random.random() * 2 - 1 transform_t[i, 3] = augmentation_dict['offset'] * random_float An affine grid and `grid_sample` then resample the CT tensor using that transform. The same pipeline can incorporate flips, scaling, and rotation; noise is added to the resampled chunk. Cache the original chunk before augmentation, or the cache will preserve just one altered version instead of allowing fresh variations. section 14.6.1 section 14.6.1
Augmentation can help a model see an object in different positions, but it does not erase architectural limitations. A fully connected image classifier can require substantial capacity to learn translated copies of the same airplane; convolutional models address that mismatch through their structure. Augmentation is therefore a training choice, not a substitute for choosing a suitable model. section 7.2.6
Check whether the chosen changes help rather than assuming they will. Train an unaugmented baseline, separate runs for each alteration, and a run combining them; then compare validation loss, F1 score, precision, and recall in TensorBoard. The combined CT augmentation run differs from the individual runs, so the validation metrics—not the apparent number of new samples—should guide the choice. Further experiments can vary the strength of noise or offsets and test whether noise helps at all. section 14.6.2 section 14.8
Listing 14.12 Applying affine transformation
transform_t = torch.eye(4)
# ... #1
# ... line 195
affine_t = F.affine_grid(
transform_t[:3].unsqueeze(0).to(torch.float32),
ct_t.size(),
align_corners=False,
)
augmented_chunk = F.grid_sample(
ct_t,
affine_t,
padding_mode='border',
align_corners=False,
).to('cpu')
# ... line 214
return augmented_chunk[0], center_irc
The affine-grid and sampling listing shows how a transformed CT candidate is produced from the transformation matrix. section 14.6.1








