CNN Architectures & Applications: LeNet-5 to Transfer Learning

Explore key CNN architectures like LeNet-5, understand design principles, and discover transfer learning applications in computer vision. Master CNNs!

Chapter 9: Convolutional Neural Network (CNN) Architectures & Applications

This chapter explores foundational and advanced Convolutional Neural Network (CNN) architectures, detailing their design principles and diverse applications. We will also delve into the powerful concept of transfer learning and its practical implementations.

9.1 Key CNN Architectures

This section provides an overview of significant CNN architectures that have shaped the field of computer vision.

9.1.1 LeNet-5

  • Description: One of the earliest successful CNN architectures, developed by Yann LeCun in the early 1990s. It was instrumental in character recognition tasks, particularly for handwritten digits.
  • Key Features:
    • Consists of convolutional layers, pooling layers, and fully connected layers.
    • Employed average pooling.
    • Used tanh activation functions.
  • Application: Handwritten digit recognition (e.g., postal codes).

9.1.2 AlexNet

  • Description: A breakthrough CNN that won the ImageNet Large Scale Visual Recognition Challenge (ILSVRC) in 2012. Its success demonstrated the power of deep CNNs for image classification.
  • Key Features:
    • Deeper than LeNet, with five convolutional layers and three fully connected layers.
    • Introduced the use of ReLU (Rectified Linear Unit) activation functions, which significantly improved training speed.
    • Utilized dropout for regularization to prevent overfitting.
    • Employed GPU acceleration for training.
  • Application: Large-scale image classification, object recognition.

9.1.3 VGG (Visual Geometry Group)

  • Description: Developed by the VGG group at the University of Oxford. VGG architectures are known for their simplicity and uniformity, primarily using small 3x3 convolutional filters stacked together.
  • Key Features:
    • VGG-16 and VGG-19: These are the most common variants, characterized by their depth (16 and 19 weight layers, respectively).
    • Small Convolutional Filters: Consistently uses 3x3 convolutional filters, which allows for a larger receptive field when stacked deeply, while maintaining fewer parameters compared to larger filters.
    • Max Pooling: Employs max pooling layers to reduce spatial dimensions.
  • Application: Image classification, feature extraction for other tasks.

9.1.4 GoogLeNet (Inception v1)

  • Description: Introduced by Google, GoogLeNet achieved state-of-the-art performance in ILSVRC 2014. Its innovation lies in the "Inception module."
  • Key Features:
    • Inception Module: This module allows the network to learn features at different scales simultaneously by using multiple filter sizes (1x1, 3x3, 5x5) and a pooling operation in parallel.
    • 1x1 Convolutions: Used extensively for dimensionality reduction and feature pooling across channels, making the network more computationally efficient.
    • Auxiliary Classifiers: Used during training to combat the vanishing gradient problem in deeper layers.
  • Application: Image classification, object detection.

9.1.5 Residual Networks (ResNet)

  • Description: Developed by Kaiming He et al. at Microsoft Research, ResNet revolutionized deep learning by enabling the training of extremely deep neural networks (over 100 layers).

  • Key Features:

    • Residual Blocks: The core innovation is the "residual block," which uses "skip connections" (or shortcut connections). These connections allow gradients to flow directly through the network, bypassing one or more layers.
    • Identity Mapping: The residual block learns a residual mapping $F(x)$ instead of directly learning the desired underlying mapping $H(x)$. The output is $H(x) = F(x) + x$.
    • Enables Extreme Depth: This mechanism effectively mitigates the vanishing gradient problem, allowing for networks with hundreds or even thousands of layers.
  • Example (Simplified Residual Block):

    Input (x) -> Conv -> BatchNorm -> ReLU -> Conv -> BatchNorm -> Add (x) -> ReLU -> Output
  • Application: Image classification, object detection, semantic segmentation, and many other computer vision tasks where extreme depth is beneficial.

9.2 Deep Transfer Learning

  • Description: Transfer learning is a machine learning technique where a model trained on one task is repurposed on a second related task. Deep transfer learning specifically leverages pre-trained deep neural networks.
  • Why it's Important:
    • Reduced Training Time: Saves significant time and computational resources by avoiding training a model from scratch.
    • Improved Performance: Often leads to better performance, especially when the target dataset is small, as the pre-trained model has already learned rich, generalizable features.
    • Data Efficiency: Enables building effective models with less labeled data.
  • Common Strategies:
    • Feature Extraction: Use the pre-trained model as a fixed feature extractor. The convolutional layers' weights are frozen, and only the final classification layers are retrained on the new dataset.
    • Fine-tuning: Unfreeze some or all of the pre-trained model's layers and retrain them on the new dataset, usually with a lower learning rate. This allows the model to adapt its learned features to the new task.
  • Applications: Image classification, object detection, natural language processing (NLP), audio analysis.

9.2.1 Image Recognition with MobileNet

  • Description: MobileNets are a family of efficient convolutional neural networks designed for mobile and embedded vision applications. They are optimized for low latency and low power consumption.
  • Key Innovation: Depthwise Separable Convolutions: MobileNets significantly reduce the number of parameters and computations by using depthwise separable convolutions. This decomposes a standard convolution into two steps:
    1. Depthwise Convolution: Applies a single filter to each input channel.
    2. Pointwise Convolution: Uses 1x1 convolutions to combine the outputs of the depthwise convolution across channels.
  • Application: Real-time image classification, object detection, and segmentation on resource-constrained devices like smartphones.

9.3 Advanced Concepts & Applications

9.3.1 Top Pre-trained Models in Natural Language Processing (NLP)

While this chapter primarily focuses on computer vision, it's worth noting that pre-trained models are also crucial in NLP. Models like BERT, GPT (Generative Pre-trained Transformer), and RoBERTa are trained on massive text corpora and can be fine-tuned for a wide range of NLP tasks such as text classification, sentiment analysis, question answering, and machine translation.

9.3.2 Understanding Transfer Learning (Further Detail)

  • Scenario: Imagine training a model to classify dog breeds. If you already have a powerful CNN (like ResNet or VGG) pre-trained on millions of diverse images (e.g., ImageNet), you can leverage this pre-existing knowledge.
  • Process:
    1. Load Pre-trained Model: Load the architecture and weights of a model like ResNet50.
    2. Remove Original Classifier: Discard the final classification layer (which was trained for ImageNet's 1000 classes).
    3. Add New Classifier: Add a new classification layer suitable for your specific task (e.g., a layer with 10 output units if you have 10 dog breeds).
    4. Train (Feature Extraction or Fine-tuning):
      • Feature Extraction: Freeze the weights of all convolutional layers and train only the newly added classifier. This is fast and works well if your dataset is small.
      • Fine-tuning: Unfreeze the last few convolutional layers (or all of them) and train them along with the new classifier, using a low learning rate. This allows the model to adapt its learned features more precisely.

9.3.3 Residual Networks (ResNet) – Deep Learning (Further Detail)

  • The Problem of Deep Networks: As neural networks get deeper, training becomes increasingly difficult due to the vanishing gradient problem. Gradients can become extremely small during backpropagation, preventing the earlier layers from learning effectively.
  • The ResNet Solution: The skip connection in ResNet allows gradients to bypass layers and propagate more directly to earlier layers. This helps maintain gradient magnitude and enables the training of networks that are orders of magnitude deeper than previously possible.
  • Benefits:
    • Dramatically improved accuracy on complex tasks.
    • Enables learning of highly abstract and hierarchical features.
    • Has become a cornerstone architecture in modern deep learning for vision.