title: Calculate dimension of feature maps in convolutional neural network
body: <p>I have convolutional neural network in Keras.
  I need to know the dimensions of the feature maps in each layer.
  My input is 28 by 28 pixel image. I know theres a way to calculate this I not sure how. Below is my code snippet using Keras.</p>
  
  <pre><code>img_rows, img_cols = 28, 28
  nb_filters = 32
  nb_pool = 2
  nb_conv = 3
  
  model = Sequential()
  
  model.add(Convolution2D(nb_filters, nb_conv, nb_conv, border_mode='valid', input_shape=(1, img_rows, img_cols)))
  model.add(Activation('relu'))
  model.add(Convolution2D(nb_filters, nb_conv, nb_conv))
  model.add(Activation('relu'))
  model.add(MaxPooling2D(pool_size=(nb_pool, nb_pool)))
  model.add(Dropout(0.25))
  
  model.add(Convolution2D(64, nb_conv, nb_conv, border_mode='valid'))
  model.add(Activation('relu'))
  model.add(Convolution2D(64, nb_conv, nb_conv))
  model.add(Activation('relu'))
  model.add(MaxPooling2D(pool_size=(nb_pool, nb_pool)))
  model.add(Dropout(0.25))
  
  model.add(Flatten())
  model.add(Dense(512))
  model.add(Activation('relu'))
  model.add(Dropout(0.5))
  
  
  model.add(Dense(nb_classes))
  model.add(Activation('softmax'))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/FypHL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FypHL.jpg" alt="What i want to draw"></a></p>
  
  <p>At the end of the day, this is what i want to draw. Thank you.</p>