liveBook · Manning

Convolutional layer

As explained in Evolutionary Deep Learning: Genetic algorithms and neural networks

A convolutional layer applies learned local filters across structured input locations to detect spatial or otherwise local patterns.

A convolutional layer applies learned filters, also called kernels, across an image. Each filter slides over local patches—typically one pixel at a time—and produces output values that form a feature map. The filter weights are learned, so different filters can extract different image features. section 7.1

In Keras, `Conv2D` specifies the number of filters, kernel dimensions, activation, padding, and, for the first layer, input shape. A simple Fashion-MNIST feature extractor starts with 64 filters on a 28×28×1 image, then uses 32 and 16 filters in later convolutional layers. section 7.1

Listing 7.2 EDL_7_1_Keras_CNN.ipynb: Building CNN layers
model = models.Sequential()
model.add(layers.Conv2D(64, (3, 3), activation='relu', padding="same", 
 input_shape=(28, 28, 1)))                                 #1
model.add(layers.MaxPooling2D((2, 2), padding="same"))       #2
model.add(layers.Conv2D(32, (3, 3), activation='relu', 
 [padding="same"))                                         #3
model.add(layers.MaxPooling2D((2, 2)))                       #4
model.add(layers.Conv2D(16, (3, 3), activation='relu'))      #5
model.add(layers.MaxPooling2D((2, 2)))                       #6
 
model.summary()

This sequential model alternates `Conv2D` and `MaxPooling2D`: convolutions expand or transform channels, while pooling reduces spatial dimensions between feature-extraction stages. section 7.1

Convolutional layers are combined with neighboring layer types for different jobs:

  • Use max pooling after convolution to summarize feature maps and reduce their spatial size. section 7.1
  • Use convolution plus pooling in an autoencoder encoder to form a latent image representation. section 8.1.2
  • Use convolution plus upsampling in an autoencoder decoder to rebuild an image, ending with a layer that produces the required channel count. section 8.1.2
  • Encode filter count and kernel size as gene values when evolving CNN or autoencoder architectures. section 8.2.1

A convolutional autoencoder path

For a grayscale 28×28 input, an encoder can apply 64, 32, and 16-filter convolutional layers with 3×3 kernels, pooling after each layer. A decoder then convolves and upsamples through corresponding stages before a final one-filter convolution restores a single-channel output. section 8.1.2

Layer design remains an experimental task. Change kernel sizes, pooling sizes, or the number of convolutional layers and rerun the model to inspect the effect. Because choosing an effective CNN architecture can be difficult, filter counts and kernel sizes can also become variables in an evolutionary search. section 7.1.2 section 7.2

How Evolutionary Deep Learning: Genetic algorithms and neural networks covers it

How deep it goes
Demonstrates sliding learned filters and Keras layer construction, then encodes filter and kernel choices for evolutionary architectures.
Examples
Uses Fashion-MNIST CNNs, a 28×28 grayscale convolutional autoencoder, and randomly generated architecture gene sequences.
What it assumes
Assumes image tensors and Keras model setup while introducing convolutional-layer configuration through explicit layer definitions.
What you can do after
Apply it via Keras Conv2D to assemble CNN and autoencoder feature-extraction paths and vary their architecture parameters.
How it connects
Connects convolutional layers with MaxPooling2D, UpSampling2D, autoencoders, BatchNormalization, Dropout, and evolutionary optimization.

Also explained in

Compare how 14 books explain convolutional layer →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Evolutionary Deep Learning: Genetic algorithms and neural networks. The section links point to the parts of the book it draws on.