liveBook · Manning

Convolutional neural network

As explained in Learn Generative AI with PyTorch

A neural network architecture using convolution operations, here applied to multidimensional music data to extract spatial features.

A convolutional neural network (CNN) processes grid-like data by connecting each neuron to a local input region and reusing shared weights across positions. This reduces parameters compared with fully connected networks and helps detect spatial patterns efficiently. section 4.2

A CNN’s main operations separate feature extraction from spatial resizing:

  • Convolutional layers apply learnable filters, or kernels, to detect patterns such as edges and textures at different spatial scales. section 4.2
  • Kernel size, stride, and zero-padding determine how convolution changes the spatial dimensions and degree of downsampling. section 4.0 section 4.2
  • Transposed convolutional layers perform the complementary task of upsampling, producing higher-resolution feature maps for image generation. section 4.6
  • Two-dimensional batch normalization normalizes each feature channel to stabilize and accelerate training. section 4.6

High-resolution image generation

A discriminator can use convolutional layers to extract increasingly hierarchical features from color images, while a generator mirrors those stages with transposed convolutions to produce high-resolution outputs. This approach supports anime-face generation and CNN-based VAE models for human face images. section 4.0 section 7.3.2

Figure 7.6 The architecture of a VAE and the steps to train one to generate human face images. A VAE consists of an encoder (middle upper left) and a decoder (middle bottom right). In each iteration of training, human face images are fed to the encoder (step 1). The encoder compresses the images to probabilistic points in the latent space (step 2; since we assume normal distributions, each probability point is characterized by a vector of means and a vector of standard deviations). We then sample encodings from the distribution and present them to the decoder. The decoder takes sampled encodings (step 3) and reconstructs images (step 4). The VAE adjusts its parameters to minimize the sum of reconstruction loss and the KL divergence. The KL divergence measures the difference between the encoder’s output and a standard normal distribution.

Trace how CNN-based encoder and decoder components fit into a VAE training loop: encode images, sample latent representations, reconstruct images, and update parameters. section 7.3.2

How Learn Generative AI with PyTorch covers it

How deep it goes
Explains local connectivity, shared weights, filters, kernel size, stride, padding, upsampling, and batch normalization without detailed derivations.
Examples
Demonstrates anime-face generation, high-resolution color images, and human-face reconstruction with an eyeglasses dataset.
What you can do after
Build it from scratch into image-generation systems using convolutional and transposed convolutional layers.
How it connects
Connects convolutional layers with fully connected layers, feature extraction, transposed convolution, batch normalization, GANs, and variational autoencoders.

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 Learn Generative AI with PyTorch. The section links point to the parts of the book it draws on.