title: Fractional Max Pooling in Tensorflow
body: <p>When using the function <code>tf.nn.fractional_max_pool</code> in Tensorflow, in addition to the output pooled tensor it returns, it also returns a <code>row_pooling_sequence</code> and a <code>col_pooling_sequence</code>, which I presume is used in backpropagation to find the gradient of. This is in contrast to the normal $2 \times 2$ max pooling, which just returns the pooled tensor.</p>
  
  <p>My question is: do we have to handle the row_pooling and col_pooling values ourselves? How would we include them into a network to get backpropagation working properly? I modified a simple convolutional neural network to use fractional max pooling instead of 2 x 2 max pooling without making use of these values and the results were much poorer, leading me to believe we must explicitly handle these. </p>
  
  <p>Here's the relevant portion of my code that makes use of the FMP:</p>
  
  <pre><code>def add_layer_ops_FMP(conv_func, x_input, W, keep_prob_layer, training_phase):
  
      h_conv = conv_func(x_input, W, stride_l = 1)
      h_BN = batch_norm(h_conv, training_phase, epsilon)
      h_elu = tf.nn.elu(h_BN) # Rectified unit layer - change accordingly
  
      def dropout_no_training(h_elu=h_elu):
          return dropout_op(h_elu, keep_prob = 1.0)
  
      def dropout_in_training(h_elu=h_elu, keep_prob_layer=keep_prob_layer):
          return dropout_op(h_elu, keep_prob = keep_prob_layer)
  
      h_drop = tf.cond(training_phase, dropout_in_training, dropout_no_training)
      h_pool, row_pooling_sequence, col_pooling_sequence = tf.nn.fractional_max_pool(h_drop) # FMP layer. See Ben Graham's paper 
  
      return h_pool
  </code></pre>
  
  <p><a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/api_docs/python/functions_and_classes/shard3/tf.nn.fractional_max_pool.md" rel="nofollow">Link to function on github.</a></p>