I am trying to understand how translation invariance is achieved in CNNs. For example, consider the following simple binary classification problem: predicting whether the letter that appears on an image is A or B.

We want our network to be translation invariant. That is, if we translate our input, the final output (i.e. the predicted probability) should be the same in both the original and the translated version of the image. Mathematically, we want:

$$y = f(T(x)) = f(x)$$

where $x$ is the original image and $T(x)$ its translated version. For example, in the following image:

enter image description here

our output $y$ must be the same.

Can someone explain how this translation invariance is achieved with the MaxPooling layers?

My view (possibly wrong)

First, I will present how I understand the network achieves this translation invariance and then I will provide an explanation why we need pooling.

  1. Given that the feature maps of a CNN are equivariant (thanks to the convolution operation) as we translate the input these feature maps vary in the same way. That is, if a feature was present in position $x$ of the feature map, after we translate the image by $T$, it will appear now in position $T(x)$. Visualizing this:

enter image description here

And as we go deeper into the network where it learns to recognizes A or B, these feature maps will follow the same behavior. So assuming multiple Conv layers (reducing the dimensionality, e.g. from input 28x28 to 2x2) eventually we will get either a black (presence of A) or a white pixel (not presence of A).

  1. The case where I think MaxPooling is useful is if we consider a slightly different input image such as in the following example.

enter image description here

Now the \ edge has move slightly to the right compared to the /. This slight translation is captured by the first Conv1 layer. But what about the Conv2 layer? Will it be able to detect the presence of the edge? enter image description here

This might not be the case as shown in the final image. In the right figure we must detect a face, but if the relative positions are slightly changed (mouth is translated slightly downwards), then we might not detect the face at all.

However, if we use a MaxPooling layer between Conv1 and Conv2 then we will get the same feature map as in the case of the original image (putting the feature again into "focus" for the next layer).

  • $\begingroup$ I'm not sure I understand your problem with the last example (with the face). Translation invariance is where if we slide the image contents around inside the image boundaries, the function output remains the same. If you slide just the mouth down, you're not doing that - you're actually distorting the image. The function output should be allowed to change in that case. $\endgroup$
    – Jack M
    Commented Sep 1, 2023 at 13:03
  • $\begingroup$ @JackM The second example is about the usefulness of MaxPooling (this is my view, probably wrong) not about the translation invariance. I try to explain how translation invariance is achieved in the first (1.) part. $\endgroup$
    – ado sar
    Commented Sep 1, 2023 at 15:40

2 Answers 2


Take a vector: $V_1 = [v_1, v_2, ..., v_n]$
Calculate the max: $m_1 = \max V_1 = v_i$
Shuffle the vector: $V_2 = mix(V_1)$
Calculate the max: $m_2 = \max V_2 = v_j$

The only possible outcome is that $m_1 = m_2$

taking the maximum creates an invariance... if you keep on staking convolution and max pooling, ending up with a single value, then you are totally invariant to translation, instead if you stop before that, you are "almost" invariant"


When you apply a convolutional layer to an image $x$, you obtain a certain list of values:

$$h_1(x), h_2(x), h_3(x), ..., h_n(x) \tag 1$$

where each $h_i$ is just the function that applies the convolutional filter to a particular patch of the image, and $n$ equals the number of patches (determined by the size of the filter, the size of the image, and the stride).

If the image $x$ consists of a solid blank background with some shape drawn on it, and you translate that shape within the image boundaries, producing a new image $x'$, now when you pass that in you'll get:

$$h_1(x'), h_2(x'), h_3(x'), ..., h_n(x') \tag 2$$

The point is that the list of values (2) is just a shuffling of the list of values (1). For example, if $h_i(x)$ is the result of lining up the kernel with the top-left of the shape in $x$, then for some $j$ the function $h_j$ will correspond to that same position for $x'$, and so $h_j(x')=h_i(x)$.

(This is not quite correct if the stride of the convolution is bigger than one - in that case what list of values you end up with depends on how the position of the shape in the image lines up with the stride, but the list (2) will still be "approximately" a shuffling of (1))

Now if the next step of your network involves piping all these values into some symmetric function such as max or sum or mean, the output of the network is guaranteed to be the same for $x'$ as for $x$.

  • $\begingroup$ As you pointed out the new output (feature map) is just a shuffling of the "original'', thanks to the equivariant property of the convolution operation. In the last paragraph, if you mean something like global (max or average) pooling then of course it will be invariant. Your last paragraph, though help me realized the importance of the symmetric function. At the end of the day, FCNs achieve translation invariance without pooling, so we don't need pooling at all. The question still remains though. Why bothering with max pooling? How it leads to a NN that is translationally invariant? $\endgroup$
    – ado sar
    Commented Sep 4, 2023 at 20:12
  • $\begingroup$ @adosar Can you give an example of a network with max pooling that you think would still be tranlationally invariant without max pooling? $\endgroup$
    – Jack M
    Commented Sep 4, 2023 at 21:15
  • $\begingroup$ Replace all MaxPooling with Conv and then just take a GlobalMaxPooling before the Dense layer. $\endgroup$
    – ado sar
    Commented Sep 4, 2023 at 21:45
  • $\begingroup$ Seel also this question. I am completely lost :). $\endgroup$
    – ado sar
    Commented Sep 4, 2023 at 21:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .