A feature map goes through pooling with stride , giving a output. The gradient of the loss with respect to that output is . What is the gradient with respect to for max pooling and for average pooling?
Deep learning, Convolutional networks
Level L2 Elementary. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can route gradients backwards through pooling layers, which have no weights but still affect backpropagation.
Key idea
Max pooling passes the whole upstream gradient to the position of the maximum in each window (the "winner") and zero to the others. Average pooling splits the upstream gradient equally, so each of the inputs gets .
Steps
- Split into four windows. Top-left , top-right , bottom-left , bottom-right .
- Forward max pooling. The maxima are , so the output is . Their positions (row, column) are , , and .
- Backward max pooling. Put each upstream gradient at its window's winner and zero elsewhere. , , , . All other 12 entries are .
- Forward average pooling. The window means are , , and . They are not needed for the backward pass.
- Backward average pooling. Each input in a window gets , since . The top-left window gets in every cell, top-right , bottom-left and bottom-right .
- Check. The sum of equals the sum of in both cases (), because each window passes on exactly the gradient it received.
Common mistakes
- Dividing the gradient by in max pooling, or not dividing in average pooling.
- Forgetting that the winner positions must be stored during the forward pass, and recomputed from the stored indices.
- Spreading the max-pooling gradient to all positions that tie for the maximum, when frameworks give it to one of them (typically the first).
- Assuming overlapping windows (stride smaller than window size) work the same way. There an input can win in several windows, and its gradients are added.
How long your answer should be
Half a page with the two gradient matrices; 3–4 minutes.
Last checked on 4 December 2026.
Read this
Previous in Deep learning: A network uses cosine annealing without restarts from down to over steps: . What is the learning rate at , and why is cosine decay often preferred over step decay?
Next in Deep learning: A network has two layers with no activation function. Layer 1 is with , . Layer 2 is with , . What single layer does the same job, and does it agree with the two layers at ?