liveBook · Manning

Mirror

As explained in Deep Learning with PyTorch, Second Edition

An augmentation operation that flips an input to create a reflected variant.

Mirror is a data-augmentation operation that flips an image along one or more axes, creating a reflected training variant while preserving its pixel values. For CT samples, left-right and front-back flips can remain representative when tumor growth has no strong correlation with those directions; valid axes depend on domain knowledge. section 14.6.1

A practical mirror augmentation:

  • Adds the flip option to the augmentation configuration. section 14.6.1
  • Changes orientation without changing pixel values, so the sample remains useful but is not identical. section 14.6.1
  • Applies augmentation after caching; otherwise an already augmented sample may be persisted and reused. section 14.6.1
Listing 14.13 Flipping images to augment
for i in range(3):
  if 'flip' in augmentation_dict:
    if random.random() > 0.5:
      transform_t[i,i] *= -1

See the short PyTorch loop that randomly negates selected diagonal entries of the transformation matrix to flip image axes. section 14.6.1

How Deep Learning with PyTorch, Second Edition covers it

How deep it goes
Explains axis choice, pixel preservation, random selection, and caching order, but defers broader augmentation mechanics.
Examples
Demonstrates up-down, left-right, and front-back flips, including randomized CT-axis flips in PyTorch.
What you can do after
Apply it via PyTorch augmentation code by randomly negating selected transformation-matrix axes.
How it connects
Connects data augmentation with affine transformation, image orientation, caching, and PyTorch tensor operations.

Also explained in

Compare how 2 books explain mirror →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with PyTorch, Second Edition. The section links point to the parts of the book it draws on.