Skip to main content
Tweeted twitter.com/StackMma/status/1021998485934166017
typo
Link
H42
  • 3.5k
  • 8
  • 19

Why would a symmetric image have aan asymmetric PoolingLayer-Gradient Image?

Source Link
H42
  • 3.5k
  • 8
  • 19

Why would a symmetric image have a asymmetric PoolingLayer-Gradient Image?

I have a symmetric image img. For simplicity, I would use the below image as my example:

img = Rasterize@Graphics[{Red, Rectangle[]}]

enter image description here

As you can see, img is an image of a pure red square with four thin white margins. Now I put it into a neural network with a pooling layer only (and the PartLayer which is used to extract the red color), and then extract the gradient.

pool = NetChain[{PoolingLayer[10, "Input" -> "Image"], PartLayer[1]}]
grad = pool[img, NetPortGradient["Input"]];
gIm = grad // NetDecoder["Image"]

enter image description here

As you can see, the gradient image has a "black-L" at the margin.

The input image is symmetric, while the pooling layer (and the PartLayer) have no parameters to be trained. That means everything should be symmetric, but the gradient is asymmetric. Why?

Many thanks!