DEV Community

Cover image for Machine Learning -  Max Pooling With Color Images
Sandeep Balachandran
Sandeep Balachandran

Posted on

Machine Learning - Max Pooling With Color Images

Hey there,
Quarantined? No worries. I got new a post to forgot everything and to have some fun during this pandemic.

Let's see how we can perform max-pooling in our 3D convoluted output. In essence, max-pooling works the same way as it did for gray-scale images.
The only difference is that now we have to perform max pooling
on each convoluted output.

Let's see an example.
For simplicity, let's suppose that our 3D convoluted output looks like this.

details

As before, we will use a window size of two-by-two, and a stride of two to perform max pooling. We start by placing our window on the top left-hand corner on each convoluted output.

details

We now perform max-pooling on each convoluted output. For example, the values in our two-by-two window in the top
convoluted output are 1, 9, 5, and 4. Since 9 is the maximum value, which is 9 and put it in our output array.

details

Similarly, the values in our two-by-two window in the middle convoluted output are 9, 1,5, and 6. Since 9 is the maximum value, we will choose 9 and put it in our output array.

details

Similarly, the values in our two-by-two window, in the bottom convoluted output are 7, 6, 5, and 2. Since 7 is the maximum value, we choose 7 and put it in our output array.

details

Continuing in this fashion, we get the following result.

details

As we can see, after performing max-pooling we end up with three, two-dimensional arrays where each two-dimensional array is half the size of its corresponding convoluted output.
Therefore, in this particular case, when we perform max-pooling on the 3D convoluted output, we get a 3D array that is half the width and height of the convoluted output, but has the same depth.

details

That's all the theory we need for now. I will add the code shortly.
Lets talk about validation my next post.

Top comments (0)