Flattening layer in Computer Vision

Prashant Dixit
Geek Culture
Published in
2 min readAug 30, 2021

In this article, You will understand what is Flattening, why it is necessary to be included in Computer Vision architecture, and what will happen if we forget to add it to Network.

What is Flattening?

Rather than jumping to technical language, let’s understand it in simple words. Flattening is a process that converts the Multi-dimensional Pooled Feature map into One Dimensional vector.

Flattening on Multi-Dimensional Pooled Feature map (Credits: Super Data Science and Codicals)

Before understanding the necessity of Flattening, let’s take a quick insight into the Architecture of Computer vision.

Image → Convolution process → Feature Map → Pooling process → Pooled Feature map → Flattening → One Dimensional Vector

Summarizing it all in an image for better understanding

The architecture of Computer Vision Network mentioning Flattening layer at last (Credits: Towards Data Science and Codicals )

Why Flattening is important in every Computer Vision Network?

From the above image, it would be clear that we use a Flattening layer to convert multi-dimensional pooled and convolved Feature maps into One Dimensional vector.

This is important because we want to insert this Pooled Feature map into Neural Network and Neural Network can take only One Dimensional input that’s the main reason we using a Flattening layer in Computer Vision Architecture.

We use the Convolution and Pooling layer again and again in the Network to extract the features and create a Feature map whereas the Flattening layer is applied only once before we give it to as an input of Neural Network.

What happens if we forget to add a Flattening layer into Architecture?

This is a very crucial part of Computer Vision Architecture, we can never forget it. But then also the consequences will be that we will not be able to train our Network because we are not able to give our data to Network. Our Network cannot work with the Flattening layer, Now you would be understanding the importance of this layer that does pretty simple work but it plays important role in Network.

Flattening is a really easy topic, with its simple role in Networks. I hope you have learnt something new from this article.

Stay tuned, Keep Learning.

--

--

Prashant Dixit
Geek Culture

AI/Computer Vision/LLM Researcher • Open-source ML • Building AI/GenAI applications • Writing for making Life easier https://x.com/Prashant_Dixit0