← Neural NetworksToolsInVisionLearning Center
Convolutional Neural Networks · Lesson 53

Flattening Feature Maps

Turn several feature maps into an ordered vector while preserving their values and keeping separate images separate.

Watch the lesson

Flattening Feature Maps explained visually

2:20

Turn several feature maps into an ordered vector while preserving their values and keeping separate images separate.

Lesson overview

What you will learn

Follow filters, pooling, flattening, and classification through complete CNN examples.

  1. Reorganize values without summarizing them
  2. Follow a consistent ordering
  3. Separate flattening from pooling
  4. Preserve the batch dimension
01

Reorganize values without summarizing them

A delivery report may collect entries from several small forms into one ordered list. Flattening similarly changes the shape of a representation. It does not average values or select only the largest ones.

For one image, three feature maps of shape 2 × 2 contain 3 × 2 × 2 = 12 values. Flattening the feature dimensions gives a vector of length 12.

02

Follow a consistent ordering

If one map has rows [1, 2] and [3, 4], a row-by-row traversal yields [1, 2, 3, 4]. Continue through the other maps using the same chosen layout.

The exact order depends on the tensor layout and operation. Training and prediction must use compatible ordering so that each later weight receives the intended feature.

03

Separate flattening from pooling

Pooling usually combines several values into fewer summaries. Flattening keeps the number of values and their numerical contents unchanged.

The output is no longer presented as a two-dimensional grid. If its original shape and ordering are known, the vector can be reshaped back into the original maps. The representation changes; the values are not destroyed.

04

Preserve the batch dimension

For a batch of B images with three 2 × 2 maps each, flattening only the feature dimensions produces shape B × 12. Each row remains one image.

Flattening has no trainable weights. Its role is to prepare the feature representation for an operation such as a fully connected layer.

Knowledge check

Quick check: test your understanding

How many values come from three 2 × 2 feature maps?

12 values.

Does flattening calculate a maximum or average?

No. It rearranges the existing values without reducing their count.

What should happen to the batch dimension?

Keep it separate. Flatten each image’s feature dimensions rather than merging all images into one vector.

Accessible referenceLesson 53 transcript314 words · Matches the published narration and captionsOpen transcript

Imagine preparing a delivery report. Information is arranged in several small tables. To send it to another system, you place the entries into one ordered list. The information stays the same. Only its arrangement changes. Flattening performs a similar operation in a neural network. It reshapes feature maps into a single feature vector.

Suppose a network produces three feature maps. Each map has two rows and two columns. That gives four values in each map and twelve values altogether. Flattening turns those twelve values into one vector containing twelve entries. For a simple ordering example, imagine that the first map has one and two in its first row, followed by three and four in its second row.

If we read that map row by row, its entries become one, two, three, and four. We then continue through the remaining maps using the same consistent ordering. The exact order depends on how the data is stored. What matters is that the arrangement remains consistent during training and when the model is used.

Flattening does not calculate averages. It does not select maximum values, and it does not remove entries. This makes it different from pooling, which summarizes regions and usually discards information. Flattening also has no learned weights. It changes the shape of the data without learning a new calculation.

The original grid is no longer presented as rows and columns. However, if we know the original shape and ordering, we can reshape the vector back into those grids. When processing a batch of images, we normally keep the images separate. We flatten the feature dimensions within each image rather than combining every image into one large vector.

The resulting vector can be passed to a fully connected layer. That layer can combine the features to support a prediction. In the next lesson, we will follow that process from a feature vector to class scores.