title: How to choose the number of units for the Dense layer in the Convoluted neural network for a Image classification problem?
body: <pre><code>from keras import layers
  from keras import models
  model = models.Sequential()
  model.add(layers.Conv2D(32, (3, 3), activation='relu',
  input_shape=(150, 150, 3)))
  model.add(layers.MaxPooling2D((2, 2)))
  model.add(layers.Conv2D(64, (3, 3), activation='relu'))
  model.add(layers.MaxPooling2D((2, 2)))
  model.add(layers.Conv2D(128, (3, 3), activation='relu'))
  model.add(layers.MaxPooling2D((2, 2)))
  model.add(layers.Conv2D(128, (3, 3), activation='relu'))
  model.add(layers.MaxPooling2D((2, 2)))
  model.add(layers.Flatten())
  model.add(layers.Dense(512, activation='relu'))
  model.add(layers.Dense(1, activation='sigmoid'))
  </code></pre>
  <p>While reading the code for a binary classification problem on classifying images as either cats or dogs,
  in the Dense layer, they used 512 units. How did they come up with that? Is there a formula to get the number of units in the Dense layer. Usually if there are many features, we choose large number of units in the Dense layer.But here how do we identify the features?I know that the output Dense layer has one unit as its a binary classification problem so the out put will either be 0 or 1 by sigmoid function.</p>