Lecture Note: Unimodal Representation - Part 1 (CNNs)

11-777 Multimodal Machine Learning CMU Fall 2023
Instructor: Dr. Louis-Philippe Morency | Co-lecturer: Dr. Paul Pu Liang
Author: Yi-Jing Sie

Overview

This post starts with an introduction to the most fundamental building block of representation for different types of unimodal data, and then takes a deeper dive into image representations, covering Convolutional Neural Networks (CNNs), Region-based CNNs (R-CNNs), and CNN visualization techniques.

Unimodal Representations

Representations are the foundational building blocks for unimodal deep learning. Each data type, whether it is an image, acoustic signal, or text has unique characteristics that require tailored processing methods. For example, visual data is typically processed as arrays of pixels, while language, before LLMs, relies on structures like bag-of-words or one-hot vectors.

Image Representations

Extracting features from visual data has evolved significantly over the past decades, progressing from image gradients, edge detection, histograms of oriented gradients, and optical flow to Convolutional Neural Networks (CNNs).

Fully-connected Network

Using a fully-connected network (MLP) for visual representation is computationally inefficient because the number of learnable parameters grows with the size of the input image. Specifically, a 1-channel image with a resolution of size $480\times720$ requires 480*720*n learnable parameters, where n is the number of kernel neurons.

Grid Image

Convolutional Neural Networks (CNNs)

Convolutional layers leverage sliding windows and weight sharing to efficiently extract local features from images. Their key advantages include:

  • Inspired from visual cortex
  • Encourages visual abstraction
  • Exploits translation invariance
  • Fewer parameters than MLP/fully-connected network

To encourage feature abstraction and summarization, pooling layers are employed. Therefore, a typical CNN architecture stacks multiple convolutional layers, each followed by a non-linear activation function and a pooling layer. This pattern is repeated multiple times to learn increasingly abstract feature representations. The extracted features are then passed to one or more fully connected layers (MLP), which perform the downstream task, such as image classification.

Region-based CNNs (R-CNNs)

For localization tasks like object detection and segmentation, region proposal algorithms are employed to identify hundreds of potential regions, and then a CNN model takes as input those regions to locate objects in an image.

Selective Search [Uijlings et al., IJCV 2013] is one of the most popular region proposal algorithms. It first applies Efficient Graph-Based Image Segmentation to partition an image into regions, and then applies the Hierarchical Grouping Algorithm to recursively group similar neighboring regions in a bottom-up manner, generating region proposals at multiple scales.

  • R-CNN [Girshick et al., CVPR 2014]: combines Selective Search with CNNs for object detection. It first applies a region proposal method to get ~2k region proposals, then warps each region proposal to a fixed size and extracts a feature vector from each warped proposal with a CNN. Finally, class-specific classifiers and bounding-box regressors are applied to classify each feature vector and refine its location.
  • Fast R-CNN [Girshick, ICCV 2015]: accelerates R-CNN by computing convolutional features for the entire image only once. The model first processes the input image with a CNN to generate a shared convolutional feature map. Region proposals are then projected onto this feature map, where a Region of Interest (RoI) Pooling layer extracts fixed-size feature vectors for each projected proposal.
  • Faster R-CNN [Ren et al., NeurIPS 2015]: further improves Fast R-CNN by replacing the Selective Search algorithm with a learnable Region Proposal Network (RPN).
Grid Image
Grid Image
Grid Image

CNNs Visualization

The feature maps generated by the final convolutional layer encode the high-level representation learned by CNNs. Over the years, several techniques have been developed to visualize and interpret these learned representations, including:

  • Class Activation Mapping (CAM) [Zhou et al., CVPR 2016]: applies a Global Average Pooling (GAP) to the final feature maps, allowing class-specific weights from the following fully-connected layer to be projected back onto the feature maps.
  • Grad-CAM [Selvaraju et al., ICCV 2017]: generalizes CAM to a wide range of CNN-based models without requiring Global Average Pooling (GAP) layer. It computes the gradients of a target class with respect to the final convolutional feature maps and uses these gradients to weight the final feature maps.

Key Takeaways

1. CNNs for image representations

Compared with fully connected networks (MLPs), CNNs offer several key advantages for image representation, including: parameter efficiency, translation invariance, and high-level visual abstraction.


2. Region-based CNNs

For localization tasks like object detection and segmentation, region proposals are employed to identify candidate object regions before passing them to a CNN detector.


3. CNNs Visualization

To visualize the high-level visual representations learned by CNNs, CAM and Grad-CAM generate class-specific heatmaps that highlight the image regions most influential to a CNN's prediction.