Modified pooling layer

33 views
Skip to first unread message

Luca Mocerino

unread,
Oct 19, 2017, 1:22:20 PM10/19/17
to Caffe Users
It is possible to use the existing pooling layer for average pooling without change the output dimension. I will try to explain better. 
For example i've a input shape of 55x55x3 channels input feature map i want to apply average pooling using a certain window size, but the pixel values in that window have to be replaced with the average value. So the output dimension must remain equal to the input one. Is it possible with the standard pooling layer or i have to implement a custom layer ?

Przemek D

unread,
Oct 20, 2017, 7:42:30 AM10/20/17
to Caffe Users
Impossible with the standard pooling alone. However, you could add a deconvolution layer after the pooling, and match its parameters (kernel size & stride) with the pooling params, so that it upsamples the output to your desired original shape. If you initialize the weights with the constant value of 1 it should preserve the values calculated by the pooling layer.

Luca Mocerino

unread,
Oct 21, 2017, 6:11:20 AM10/21/17
to Caffe Users
Can you show me an example ?

Przemek D

unread,
Oct 24, 2017, 9:14:49 AM10/24/17
to Caffe Users
I have never attempted this myself, but in theory it should look something like that (suppose you want to do averaging in 2x2 window):
* first do pooling with method = AVE, kernel = 2, stride = 2
* then do deconvolution: kernel = 2, stride = 2, weight_filler: type = "constant", value = 1 and bias_term = false
Optionally you may have to crop the deconv output to match the blob you began with, if it's important to you.
Reply all
Reply to author
Forward
0 new messages