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.

In a convolutional neural network, anti-aliased pooling reduces artifacts during spatial downsampling by blurring the pooled result. A PyTorch MaxPool2dAA implementation applies max pooling with stride 1, then blurs with a filter whose size scales with the pooling factor; its default filter ratio is 1.7. 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

The implementation shows the stride-1 max-pooling step followed by blurring. section 14.1.3

Testing shifted images

On CIFAR-10, compare the correct-class probabilities for an image across 64 pixel shifts. Anti-aliased pooling makes predictions more consistent than regular pooling in the reported test, but does not eliminate aliasing. section 14.1.3

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

How deep it goes
Implements blur after stride-1 max pooling and compares training and shift-test results, while noting that aliasing remains.
Examples
Tests a CIFAR-10 CNN on 64 pixel shifts and proposes comparing probability variation across the test set.
What you can do after
Apply anti-aliasing via a PyTorch MaxPool2dAA replacement and test its effects on convergence and shifted-image predictions.
How it connects
Connects max pooling in convolutional neural networks with image translation and prediction consistency.

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.