liveBook · Manning

Convolutional neural network

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

A convolutional neural network is a neural network that processes structured inputs with learned convolutional filters, typically for tasks such as image classification.

A convolutional neural network (CNN) extends a deep-learning model with layers for localized feature extraction. It is typically used for 2D image processing, where it can improve classification and related tasks. CNNs are valuable but difficult to configure because layer type, size, placement, and hyperparameters interact. section 7.6 section 7.0

A practical CNN can be assembled as a Keras Sequential model: convolution layers extract features, max-pooling layers reduce the intermediate output, and Flatten plus Dense layers produce class outputs. For Fashion-MNIST, input images are normalized and reshaped from 2D arrays to 28×28×1 tensors so the channel dimension is explicit. section 7.1

Architecture choices require inspection rather than assuming a larger model is better:

  • Compare model summaries to track output shapes and trainable parameter counts across convolution and pooling layers. section 7.1
  • Watch training and validation results for memorization: a one-convolution-layer model can exceed 6 million parameters, fit reduced training data nearly perfectly, and perform poorly on validation data. section 7.1.1
  • Use pooling and, where appropriate, batch normalization to alter model size and layer behavior; adding pooling in the demonstrated model reduces its parameter count to about one quarter. section 7.1.1

CNN architecture can also be searched through neuroevolution. Encode a variable-length sequence of convolution, pooling, batch-normalization, and dense-layer blocks, with values for filters or neurons and kernel sizes. A decoder reads those blocks and builds the Keras model; genetic operators can then optimize architectures for a dataset. section 7.2 section 7.6

A small Fashion-MNIST CNN

Start with 1,000 training and 100 test examples to keep repeated experiments tractable. Build three Conv2D layers with 64, 32, and 16 filters, place max pooling after each, then add Flatten, a 128-unit Dense layer, and a 10-output Dense layer. Inspect the resulting 23,728 trainable parameters before training. section 7.1

Figure 7.10 The gene encoding of CNN model architecture

Inspect the variable-length encoding to see how negative block identifiers separate CNN layer types from their hyperparameter values before decoding an architecture. section 7.2

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

How deep it goes
Walks through Keras construction, parameter summaries, training behavior, pooling effects, and gene-based architecture encoding.
Examples
Uses Fashion-MNIST, a three-convolution-layer Keras model, a oversized single-layer model, and variable-length gene sequences.
What you can do after
Build from scratch a Keras CNN and encode its layer architecture for genetic optimization.
How it connects
Connects convolutional neural networks with image classification, max pooling, batch normalization, generalization, genetic algorithms, and neuroevolution.

Also explained in

Compare how 18 books explain convolutional neural network →

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.