While tweaking a deep convolutional net using Keras (with the TensorFlow backend) I would like to try out a hybrid between MaxPooling2D
and AveragePooling2D
, because both strategies seem to improve two different aspects regarding my objective.
I'm thinking about something like this:
-------
|8 | 1|
x = ---+---
|1 | 6|
-------
average_pooling(x) -> 4
max_pooling(x) -> 8
hybrid_pooling(x, alpha_max=0.0) -> 4
hybrid_pooling(x, alpha_max=0.25) -> 5
hybrid_pooling(x, alpha_max=0.5) -> 6
hybrid_pooling(x, alpha_max=0.75) -> 7
hybrid_pooling(x, alpha_max=1.0) -> 8
Or as an equation:
hybrid_pooling(x, alpha_max) =
alpha_max * max_pooling(x) + (1 - alpha_max) * average_pooling(x)
Since it looks like such a thing is not provided off the shelf, how can it be implemented in an efficient way?