title: automatically determine best filter size to use in keras CNN Conv2D layers
body: <p></p>
  
  <pre class="lang-python prettyprint-override"><code>model.add(Conv2D(32, (5, 5),
                    padding='same',
                    data_format='channels_last',
                    input_shape=input_shape))
  
  
  model.add(BatchNormalization())
  model.add(Activation('relu'))
  model.add(Conv2D(32, (3, 3)))
  model.add(BatchNormalization())
  model.add(Activation('relu'))
  model.add(MaxPooling2D(pool_size=(2, 2)))
  model.add(Dropout(0.25))
  
  model.add(Conv2D(64, (3, 3), padding='same'))
  model.add(BatchNormalization())
  model.add(Activation('relu'))
  model.add(Conv2D(64, (3, 3)))
  model.add(Activation('relu'))
  model.add(MaxPooling2D(pool_size=(2, 2)))
  model.add(Dropout(0.25))
  
  model.add(Flatten())
  model.add(Dense(512))
  model.add(Activation('relu'))
  model.add(Dropout(0.25))
  
  model.add(Dense(num_classes))
  model.add(Activation('softmax'))
  </code></pre>
  
  <p>This is what my current keras model looks like, which is completely borrowed from <a href="https://yashk2810.github.io/Applying-Convolutional-Neural-Network-on-the-MNIST-dataset/" rel="nofollow noreferrer">here</a>.</p>
  
  <p>My question has two parts,<br>
  1. How do I automatically determine whether to use         <code>model.add(Conv2D(32, (3, 3)))</code> or <code>model.add(Conv2D(32, (5,5)))</code> or <code>model.add(Conv2D(32, (4,4)))</code> ?<br>
  2. except the first line of the model, If I change the rest of the conv2D(64, (3,3)) models to (5,5) I get `negative dimension obtained by subtracting 5 from 3) . why is that?  </p>
  
  <p>I looked at these two questions : <a href="https://stackoverflow.com/questions/46065445/selecting-number-of-strides-and-filters-in-cnn-keras">Selecting number of strides and filters in CNN (Keras)</a> and <a href="https://stackoverflow.com/questions/46174757/conv2d-layer-output-shape-in-keras">Conv2D layer output shape in keras</a><br>
  according to them experimenting is the only way to find out, but I was wondering if there is an automatic way to do it.
  Because there are so many parameters such as <code>value of dropout</code> , <code>kernel_size()</code> and then value of <code>Dense()</code> should it be 512/356 or how much is the best.   </p>
  
  <p>PS:
  Running different models with different parameters is becoming computationally expensive, and comparing all these results is becoming another painful process.
  My laptop has a 2GB nvidia graphic card with 5.0 compute capability.</p>