How to understand the section “Tightly connected layer” in the textbook “Tensor flow”

The Densely Connected Layer section of the tenorflow tutorial states that the image size is 7 x 7 after it has been processed. I tried the code and it seems that these options work.

But I do not know how to get this size 7 x 7 . I understand that:

  • original image 28 x 28,
  • in the 1st level layer, the max_pool_2x2 function max_pool_2x2 reduce both image sizes by 4 times, so after the first merge operation, the image size is 7 x 7
  • HERE THAT I DO NOT UNDERSTAND.

    in the second conv layer, there is another call to the max_pool_2x2 function, so I think the image size should be reduced by 4 times. But actually he didn’t.

At what stage was I wrong?

+7
tensorflow
source share
2 answers

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: enter image description here

+20
source share

Take a look at Teach yourself deep learning with TensorFlow and Udacity with Vincent Vanhoke

This is described in the course. I am currently working on this.

The course is free, but you need to register. This is a series of videos, quizzes and coding projects, each of which in itself is evaluated. I learn a lot and enjoy it.

Here is one of the quizzes.

enter image description here

+4
source share

All Articles