liveBook · Manning

Anti-aliasing

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

A smoothing approach that reduces aliasing artifacts during sampling or downsampling by filtering before spatial reduction.

Anti-aliasing reduces prediction changes caused by image shifts by filtering around spatial reduction. In convolutional networks, anti-aliased pooling replaces regular pooling while preserving the surrounding architecture. 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

Implement anti-aliased max pooling by applying max pooling with stride 1, then passing the result through a blur layer whose filter size scales with the pooling size. section 14.1.3

A practical implementation follows these choices:

  • Use the pooling kernel size to control spatial reduction and multiply it by a ratio, defaulting to 1.7, to select the blur filter size. section 14.1.3
  • Replace each regular pooling operation with MaxPool2dAA while leaving the network, optimizer, scheduler, and training procedure unchanged. section 14.1.3

Shifted-image predictions

Evaluating all 64 pixel shifts of a CIFAR-10 image produces more consistent correct-class probabilities with anti-aliased pooling, although aliasing is not eliminated. section 14.1.3 section 14.4

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

How deep it goes
Defines a PyTorch pooling replacement, explains its blur-size parameter, and evaluates convergence and shift consistency.
Examples
Uses MaxPool2dAA, an aaPool_CNN, CIFAR-10 shift sweeps, and median probability-deviation exercises.
What it assumes
Assumes familiarity with CNNs, max pooling, training loops, and image-classification evaluation.
What you can do after
Apply it via PyTorch by replacing pooling layers and measuring accuracy, convergence, and prediction variation across image shifts.
How it connects
Connects max pooling with blurring, aliasing, translation shifts, strided convolution, and average pooling.

Also explained in

Compare how 2 books explain anti-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.