title: Cannot add SPP layer in CNN using Keras
body: <p>I want to apply Spatial Pyramid Pooling before the Dense layer in a CNN. </p>
  
  <p>I used Keras for implementation.</p>
  
  <p>Tensorflow was used as a backend.</p>
  
  <p>However, I got an error. </p>
  
  <p>What's wrong with my code? Thank you.</p>
  
  <p><code>Traceback (most recent call last):
    File "&lt;pyshell#25&gt;", line 1, in &lt;module&gt;
      model.add(SpatialPyramidPooling(pooling_regions, input_shape=Input(shape = (None,None,None,3))))
    File "C:\Program Files\Python36\lib\site-packages\spp\SpatialPyramidPooling.py", line 33, in __init__
      super(SpatialPyramidPooling, self).__init__(**kwargs)
    File "C:\Program Files\Python36\lib\site-packages\keras\engine\topology.py", line 311, in __init__
      batch_input_shape = (batch_size,) + tuple(kwargs['input_shape'])
    File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 439, in __iter__
      "Tensor objects are not iterable when eager execution is not "
  TypeError: Tensor objects are not iterable when eager execution is not enabled. To iterate over this tensor use tf.map_fn.</code></p>
  
  <p>Here is the code:</p>
  
  <pre><code>from keras.engine.topology import Layer
  from keras.models import Sequential
  import keras.backend as K
  import numpy as np
  
  model = Sequential()
  model.add(SpatialPyramidPooling((1,2,4), Input(shape=(None, None, None, 3))))
  
  class SpatialPyramidPooling(Layer):
      def __init__(self, pool_list, **kwargs):
  
          self.dim_ordering = K.image_dim_ordering()
          assert self.dim_ordering in {'tf', 'th'}, 'dim_ordering must be in {tf, th}'
  
          self.pool_list = pool_list
  
          self.num_outputs_per_channel = sum([i * i for i in pool_list])
  
          super(SpatialPyramidPooling, self).__init__(**kwargs)
  
      def call(self, x, mask=None):
  
          input_shape = K.shape(x)
          print(input_shape)
          print(K.eval(input_shape))
          outputs = K.variable(value=np.random.random((3,4)))
  
          return outputs
  </code></pre>