title: Port model from Torch to Keras
body: <p>I am trying to port the below model definition from Torch to Keras.</p>
  
  <ul>
  <li>Torch lua script</li>
  </ul>
  
  <blockquote>
  <pre><code>local model = nn.Sequential();
  -- input 3x12x12
  model:add(nn.SpatialConvolution(3, 16, 3, 3))
  -- outputs 16x10x10
  model:add(nn.SpatialMaxPooling(3, 3, 2, 2))
  model:add(nn.ReLU())
  -- outputs 16x4x4
  model:add(nn.SpatialConvolution(16, 16, 4, 4))
  model:add(nn.ReLU())
  -- outputs 16x1x1
  model:add(nn.SpatialConvolution(16, 2, 1, 1))
  -- outputs 2x1x1
  model:add(nn.SpatialSoftMax())
  </code></pre>
  </blockquote>
  
  <p><a href="https://github.com/IggyShone/fast_face_detector/blob/master/12net.lua" rel="nofollow">https://github.com/IggyShone/fast_face_detector/blob/master/12net.lua</a></p>
  
  <ul>
  <li>Ported Keras - Python script</li>
  </ul>
  
  <blockquote>
  <pre><code>model = Sequential()
  model.add(Convolution2D(16, 4, 4, input_shape=(3, 12, 12), border_mode='valid', subsample=(1, 1)))
  model.add(MaxPooling2D(pool_size=(3, 3), strides=(2, 2)))
  model.add(Activation('relu'))
  model.add(Convolution2D(16, 4, 4, input_shape=(16, 4, 4), border_mode='valid', subsample=(1, 1), activation='relu'))
  model.add(Convolution2D(2, 1, 1, input_shape=(16, 1, 1), border_mode='valid', subsample=(1, 1), activation='softmax'))
  </code></pre>
  </blockquote>
  
  <p>But when I ran the ported script, the below error happened.</p>
  
  <pre><code>Exception: Cannot apply softmax to a tensor that is not 2D or 3D. Here, ndim=4
  </code></pre>
  
  <p>It seems keras does not allow apply softmax activation for Convolution layer. How should I do to pass this error? Thank you.</p>