Keras convolution filter size issue
<p>I'm <em>very</em> new to Keras, and in my early experiments I've been encountering an error when I create convolutional layers. When I run this code (found <a href="https://keras.io/getting-started/functional-api-guide/#more-examples" rel="nofollow" title="here">here</a>; "Shared vision model" section)</p>

<pre><code>from keras.models import *
from keras.layers import *
from keras.layers.convolutional import *
from keras.layers.pooling import *

digit_input = Input(shape=(1, 27, 27))
x = Convolution2D(64, 3, 3)(digit_input)
x = MaxPooling2D((2, 2))(x)

mdl = Model(digit_input, x)
</code></pre>

<p>I get the following error (traceback points to the Convolution2D line):</p>

<pre><code>ValueError: Filter must not be larger than the input: Filter: (3, 3) Input: (1, 27)
</code></pre>

<p>I'd assume I was misusing the interface--especially since no one else seems to have this particular problem--but I pulled the code directly from the Keras docs. The problem persists when I use the <code>model.add()</code> syntax. Interestingly though, when I shrink the filter size to 1x1 or increase the number of input channels to 3, the error goes away. I have tried manually setting <code>dim_ordering='tf'</code> for the convolution and my keras.json file reads:</p>

<pre><code>{
"image_dim_ordering": "tf",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "tensorflow"
}
</code></pre>

<p>Keras looks like a great tool, but I'm completely unable to use it so far. </p>

<p>P.S. I am using Keras 1.1.0 and Tensorflow 0.10. </p>

<p>'image_dim_ordering' : 'tf' is setting the input's third dimension as the channel input to the 2D Convolution: ie you've currently put a 1x27 input with 27 channels in to be convolved with a 3x3 kernel and no padding.</p>

<p>You should be able to switch 'image_dim_ordering' to 'th' and have this code immediately work. I think 'th' used to be the default and you've unfortunately hit an obsolete tutorial. Here's the Keras documentation from <a href="https://keras.io/layers/convolutional/" rel="nofollow">Convolution2D</a> - it's there but not particularly prominent:</p>

<blockquote>
  <p>dim_ordering: 'th' or 'tf'. In 'th' mode, the channels dimension (the depth) is at index 1, in 'tf' mode is it at index 3. It defaults to the image_dim_ordering value found in your Keras config file at ~/.keras/keras.json. If you never set it, then it will be "tf".</p>
</blockquote>

<p>Hope that helps!</p>

python neural-network tensorflow convolution keras