For CNN basic knowledge, apply the first convolutional layer (5x5x32) to original image, the size of image become from
28x28x32 and to
24x24x32, both is right.
The different between
24x24x32 is the first result had padding and the second had not padding.
Why the tutorial select padding?
Because if we select NO padding, the result of features will become small, as you see from tutorial, after only one convolutional layer, the size become to
24x24x32. And if we have multiple convolutional layer, the size of feature map will become smaller and smaller, and the same time, the features will not useful anymore.
Detail from tensorflow tutorial: https://www.tensorflow.org/tutorials/layers
If filter width and height have the same value, you can instead specify a single integer for kernel_size—e.g., kernel_size=5.
padding argument specifies one of two enumerated values (case-insensitive): valid (default value) or same. To specify that the output tensor should have the same width and height values as the input tensor, we set
padding=same here, which instructs TensorFlow to add 0 values to the edges of the output tensor to preserve width and height of 28. (
Without padding, a 5x5 convolution over a 28x28 tensor will produce a 24x24 tensor, as there are 24x24 locations to extract a 5x5 tile from a 28x28 grid.)
The step explain for example could see: