liveBook · Manning

Aliasing

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

A sampling artifact in which fine-grained detail is collapsed into a smaller representation, causing distinct inputs to become indistinguishable.

Aliasing occurs when fine-grained information is sampled into a smaller representation. Distinct inputs can collapse into the same output, producing block-like artifacts and lost detail; shrinking more aggressively worsens the problem. section 14.1

In convolutional neural networks, aliasing matters because it:

  • Appears visibly as pixelated or garbled patterns when max pooling reduces detailed images, such as zebra stripes. section 14.1
  • Makes different one-dimensional patterns produce identical max-pooled outputs. section 14.1
  • Compromises translation invariance, so predictions can fluctuate as image content shifts by a few pixels. section 14.1.1
  • Also affects average pooling and convolutions with stride two or greater. section 14.1.3

Anti-aliased pooling

Reduce aliasing by separating selection from downsampling: apply max pooling with stride 1, then blur the result with a binomial-kernel convolution using the desired stride. In PyTorch, MaxPool2dAA follows this pattern and can replace ordinary max pooling. The resulting CNN gives more consistent predictions across shifted CIFAR-10 crops, although it does not eliminate aliasing completely. section 14.1.2 section 14.1.3

class MaxPool2dAA(nn.Module): 
    def __init__(self, kernel_size=2, ratio=1.7): 
        """ 
        kernel_size: how much to pool by 
        ratio: how much larger the blurring filter should be than the 
         pooling size 
        """
        super(MaxPool2dAA, self).__init__() 

        blur_ks = int(ratio*kernel_size)                   #1 
        self.blur = BlurLayer(kernel_size=blur_ks,         #2 
         stride=kernel_size, D=2) 
        self.kernel_size = kernel_size                     #3

    def forward(self, x): 
        ks = self.kernel_size 
        tmp = F.max_pool2d(x, ks, stride=1, padding=ks//2) #4 
        return self.blur(tmp)                              #5
#1 Makes a slightly larger filter for blurring
#2 Creates the blur kernel
#3 Stores the pooling size
#4 Applies pooling with stride=1
#5 Blurs the result

Inspect the MaxPool2dAA implementation, which performs stride-1 max pooling followed by a larger blur layer. section 14.1.3

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

How deep it goes
Explains sampling failure, toy patterns, image effects, shift tests, and anti-aliased pooling implementation.
Examples
Uses zebra stripes, one-dimensional binary patterns, CIFAR-10 crops, pixel shifts, and PyTorch pooling modules.
What it assumes
Assumes familiarity with CNNs, pooling, convolutions, image tensors, and PyTorch training workflows.
What you can do after
Diagnose/debug with it by testing predictions across pixel shifts and replace naive downsampling with anti-aliased pooling.
How it connects
Connects aliasing with max pooling, blurring, convolution, stride, average pooling, and translation invariance.

Also explained in

Compare how 2 books explain aliasing →

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.