<ol>
<li><p>I think the reason you have [32, 248, 248, 3] instead of the [32, 256, 256, 3] that you wanted is because of padding. Briefly, when you do a convolution, the convolutional window a.k.a. kernel doesn't necessarily fit perfectly with the image, so the image has zeroes padded on the outside to make it fit. Based on your code, padding is unspecified, so, try adding padding='same' into your conv2d layers.</p>
</li>
<li><p>You're correct here about what 64 and [5, 5] signify. The number of filters has no bearing here. The kernel is related to, though not the cause of, the gap in dimensions that you're experiencing, if my answer in (1) is correct. However, you should ideally be able to set it to 3, 5 or whatever, without issue. Refer to (1).</p>
</li>
<li><p>32 corresponds to samples, as you said. In other words, it's the batch size. The image size itself is 256 x 256 pixels (height and width). 3 channels corresponds to red, blue and green strengths for each pixel. If the image was grayscale, there would be only 1 channel. In Tensorflow, the convention is (N,H,W,C), meaning Number of samples, Height, Width, Channels. Note that channels is typically 3 at input and output, but it changes in the hidden layers according to the number of filters you use.</p>
</li>
<li><p>Decreasing and then increasing the height and width of the images is good for certain tasks, like image segmentation, where you're sort of reducing the information in the image. We call the first half of the network the encoding stage, and the second half the decoding stage. I think it eliminates unnecessary info in the first half by making the image dimensions smaller, and then restores it to original size in the second half. That's just my interpretation though. A well-known model that does this is called U-net. <a href="https://arxiv.org/abs/1505.04597" rel="nofollow noreferrer">https://arxiv.org/abs/1505.04597</a></p>
</li>
</ol>
What do the dimensions mean while using images in CNNs?
<p>Please go through the code below. Image size is (32, 256 , 256 , 6). I don't think it is necessary to know what net is and what it does. My question is purely analytical.</p>
<pre><code>      net = slim.conv2d(input_images, 64, [5, 5], stride=1, scope='conv1') 
      net = slim.max_pool2d(net, [2, 2], scope='pool1') # image size is (batch_size, 256 , 256 , 6)

      net = slim.conv2d(net, 128, [5, 5], stride=1, scope='conv2')
      net = slim.max_pool2d(net, [2, 2], scope='pool2')

      net = slim.conv2d(net, 256, [3, 3], stride=1, scope='conv3')
      net = slim.max_pool2d(net, [2, 2], scope='pool3')

      net = tf.image.resize_bilinear(net, [64,64])
      net = slim.conv2d(net, 256, [3, 3], stride=1, scope='conv4')
      
      net = tf.image.resize_bilinear(net, [128,128])
      net = slim.conv2d(net, 128, [3, 3], stride=1, scope='conv5')

      net = tf.image.resize_bilinear(net, [256,256]) #(32 , 256 , 256 , 3)

      
      net = slim.conv2d(net, 64, [5, 5], stride=1, scope='conv6')

net = slim.conv2d(net, 3, [5, 5], stride=1, activation_fn=tf.tanh,
normalizer_fn=None, scope='conv7') #  32*248*248*3
</code></pre>
<p>The dimension of net turns out to be (32, 248, 248, 3) according to me. But apparently according to the paper it should be (32, 256, 256, 3).</p>
<p>Ques1) Where did I go wrong?</p>
<p>Ques2) In slim.conv2d what exactly is 64 and [5,5]? I think they are the number of filters and 5*5 is the dimension of the kernel. But since I am getting the wrong dimensions am I wrong here too?</p>
<p>Ques3) When you say (32,256,256,3) does it mean that there are 32 samples, 256*256 is the pixel strength and 3 are the number of channels?</p>
<p>Ques4) I know this might be difficult to answer but could someone tell me what is the need to first decrease the dimensions and then increase them again? A link to the concept shall be much appreciated.</p>