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