You also need to know the maximum pool and convolution step.
def conv2d(x, W): return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME') def max_pool_2x2(x): return tf.nn.max_pool(x, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME')
Here we see that the convolution has step 1 and the maximum pool has step 2. As you can see, the maximum pool is that it takes a 2x2 square and moves it around the image, each time taking a maximum value of more than 4 pixels. If you have step 2, every time it moves, it takes 2 steps! The image size should be reduced by 2 times instead of 4.
In other words, a 28x28 image with a maximum pool of 2x2 and step 2 will become 14x14. The other maximum pool is 2x2 and step 2 will reduce it to 7x7.
To illustrate my point, let's look at the case of the maximum 2x2 pool and step 1. If we do not stick the image, it will become a 27x27 image after the maximum pool.
Here is the image for a more complete answer: 
jkschin
source share