71 min total

Generative AI

Convolutional neural networks

Convolutional neural networks

Convolutional Neural Networks

  • If you use FNNs to input 100x100 image, it will generate millions of parameters, which may lead to overfitting on training dataset.
  • In images, patterns like edges, shapes appear in multiple locations a FNN would have to relearn the same pattern for every location which is wasteful
  • Convolution applies a filter across an image, allows model to detect local features across different regions reducing the number of parameters

History of CNNs

1950-1960s neuroscientists studied visual cortex of cats and monkeys, they discovered that simple cells detect small edges or lines, complex cells combine these features to detect more complex patterns (shapes) this inspired the idea of CNNs. In image processing convolution is used to apply filters to an image to extract edges or textures. In 1980s FNNs were being used for image tasks, they required too many parameters, didn’t handle translation invariance well (recognizing an object regardless of its position inside the image). NeoCognitron 1980 was model inspired by visual cortex used shared weights to detect patterns. LeNet 1998 LeCun created convolutional layers, pooling, backprop to recognize handwritten digits, this was first practical CNN 🔥.

GenAI / Mid 01 — Convolutional neural networks

Working of CNNs [Mid1/19Feb] 👈 Ghaur se parh isko

GenAI / Mid 01 — Convolutional neural networks
GenAI / Mid 01 — Convolutional neural networks

Pooling

Types of pooling

  1. Max pooling: selects maximum value from a region of feature map
  2. Average pooling: takes average value from a region of feature map
  3. Global pooling: summarizes entire feature map into single value
  4. Min pooling: takes minimum value from a region of feature map
  5. L2 Norm pooling: computes euclidean norm of values from a region of feature map

Why do we do pooling?

  1. Dimensionality reduction - reduces parameters and computations
  2. Translation invariance - makes network less sensitive to distortions in the input image
  3. Reduces the risk of filters overfitting to pixel level details
  4. Introduced to downsample feature maps while preserving most important information

Why AlphaGo doesn’t uses maxpooling?

AlphaGo is an AI system developed by DeepMind to play ancient board Go at superhuman level

Maxpooling reduces spatial resolution of feature maps by selecting highest values in small regions, works well for images where we want to retain strongest features (edges) However in Go, every board position matters, a single misplaced move can dramatically change game's outcome, pooling could disrupt board's spatial relationships

GenAI / Mid 01 — Convolutional neural networks

Spatial information tells how elements are arranged based on their location in image

CNNs in speech recognition?

Speech is first represented as spectrograms(xaxis-time, yaxis-freq), CNNs can detect spatial features by learning patterns in spectograms

CNNs in text classification?

Represent each word as embedding matrix, apply 1D convolution, use max pooling to retain most important features, pass extracted features to FNN for classification.

GenAI / Mid 01 — Convolutional neural networks

CNN Applications

CNNs can be applied to many problems

  1. Object detection
  2. Scene parsing
  3. Indoor semantic labeling
  4. Action detection
GenAI / Mid 01 — Convolutional neural networks — notes
GenAI / Mid 01 — Convolutional neural networks — notes

Padding slang names

  1. Valid Padding - no padding
  2. Same Padding/zero padding - pads the input so that output matches input size
  3. Full Padding - feature map size gets bigger than input image size
GenAI / Mid 01 — Convolutional neural networks
GenAI / Mid 01 — Convolutional neural networks
GenAI / Mid 01 — Convolutional neural networks
GenAI / Mid 01 — Convolutional neural networks
GenAI / Mid 01 — Convolutional neural networks
GenAI / Mid 01 — Convolutional neural networks
GenAI / Mid 01 — Convolutional neural networks
GenAI / Mid 01 — Convolutional neural networks
GenAI / Mid 01 — Convolutional neural networks