session: "6103-advanced-ml/2026-10-13 1830 Advance Machine Learning"
title: "Advance Machine Learning"
date: "2026-10-13 18:30"
duration: "1h 30m"
language: "en"
model: "deepseek-ai/DeepSeek-V3.2"
parts: 2
transcript_chars: 51207
generated: "2026-11-23T00:33:48+05:30"
Advanced Machine Learning
Overview
This class introduced Convolutional Neural Networks (CNNs) as a fundamental deep learning model for image processing. It contrasted CNNs with traditional Artificial Neural Networks (ANNs), highlighting ANNs' limitations with large inputs and lack of location invariance. The lecture covered the core CNN architecture, including the convolution operation, kernels, stride, feature maps, and the purpose of pooling and activation functions. This session establishes the foundation for understanding modern computer vision models and their automatic feature extraction capabilities.
Learning outcomes
- Explain the limitations of Artificial Neural Networks for image data.
- Describe the purpose and advantages of Convolutional Neural Networks.
- Perform the convolution operation between an input matrix and a kernel.
- Explain the roles of stride, normalization, and the ReLU activation function in CNNs.
- Describe how pooling reduces feature map dimensions and its benefits.
- Explain how CNNs achieve automatic and hierarchical feature extraction.
Core concepts
CNN vs. ANN
A Convolutional Neural Network (CNN) is a neural network architecture designed for automatic feature extraction from images, fundamental to models like ResNet and MobileNet. An Artificial Neural Network (ANN), like a perceptron, requires manual feature input and is sensitive to object location. CNNs matter because they efficiently handle large input sizes (e.g., millions of pixels) and are invariant to where an object appears in an image, solving key ANN shortcomings.
Convolution Operation
Convolution is the element-wise multiplication of a small kernel matrix with patches of the input image, followed by summation, scanning the image systematically. This operation matters because it is the primary mechanism for detecting local patterns (e.g., edges, curves). It connects to the overall architecture as the first step in generating feature maps, which are then processed by activation and pooling layers.
Kernels/Filters
A kernel (also called a filter, feature detector, or convolutional matrix) is a small, user-defined matrix (e.g., 2x2, 3x3) containing weights initialized randomly. It matters because each kernel is designed to detect a specific feature, such as a loopy pattern or a vertical line. Kernels are not predefined; they are learned during training, enabling automatic feature extraction.
Feature Maps
A feature map is the output matrix resulting from the convolution of an input image with a kernel. It matters because the values within a feature map indicate the presence and approximate location of the detected feature. This connects to hierarchical learning, as combinations of simple feature maps from initial layers are used to detect more complex features in deeper layers.
Stride
Stride is the number of pixels the kernel shifts over the input matrix during convolution (common values are 1 or 2). It matters because a smaller stride allows the model to examine the image in more detail, while a larger stride reduces computational cost and output size. It is a key hyperparameter that connects to the granularity of the feature extraction process.
Pooling
Pooling (e.g., max pooling, average pooling) is a down-sampling operation that reduces the size of feature maps. It matters because it lessens computational load, provides invariance to small translations, and helps prevent overfitting by reducing detail. It typically follows convolution and activation within a CNN block.
Hierarchical Feature Learning
CNNs learn features hierarchically: low-level filters detect simple patterns (edges, curves), combinations of these detect mid-level features (eyes, nose), and further combinations detect high-level objects (face). This matters because it mimics human visual processing and allows the model to build complex understanding from simple components automatically during training.
Formulas and maths
- Convolution Operation: Element-wise multiplication of kernel and input patch, followed by summation.
- Symbols: Input patch \( I \), kernel \( K \), output feature map value \( F_{i,j} = \sum (I \odot K) \).
- Use: To generate a feature map by detecting local patterns.
- Normalization: \( \text{Normalized Sum} = \frac{\text{Sum of element-wise products}}{\text{Number of cells in kernel}} \).
- Symbols: For a 3x3 kernel, divisor is 9.
- Use: To keep convolution output values small for easier processing and weight updates.
- ReLU Activation: \( \text{ReLU}(x) = \max(0, x) \).
- Symbols: \( x \) is an input value from the feature map.
- Use: Applied after convolution to turn negative values to zero, resulting in cleaner, sparser feature maps.
- Max Pooling: \( \text{Output} = \max(\text{values in the N x N region}) \).
- Symbols: N x N is the pooling filter size (e.g., 2x2).
- Use: For down-sampling feature maps, retaining the most prominent feature in a region.
- Average Pooling: \( \text{Output} = \text{average}(\text{values in the N x N region}) \).
- Symbols: N x N is the pooling filter size.
- Use: For down-sampling feature maps, smoothing the values in a region.
- Number of Weights Between Layers: \( \text{Weights} = N \times M \).
- Symbols: \( N \) is the number of neurons in the input layer, \( M \) is the number in the next hidden layer.
- Use: To illustrate the parameter explosion in ANNs for image inputs (e.g., 6M input neurons × 4 hidden neurons = 24M weights).
Worked examples
- MNIST Dataset: 60,000 training images, 10,000 test images. Each image is grayscale, size 28x28.
- Input Neurons Calculation:
- For a 5x5 image: 25 input neurons (plus bias).
- For a 1920x1080 RGB image: \(1920 \times 1080 \times 3 \approx 6\) million input neurons.
- Convolution Example:
- Input: A 7x5 matrix representing a digit "9" (values: -1 for background, 1 for digit).
- Kernel: A 3x3 kernel designed to detect loopy patterns: \( \begin{bmatrix} 1 & 1 & 1 \\ 1 & -1 & 1 \\ 1 & 1 & 1 \end{bmatrix} \).
- First operation: Kernel placed at top-left corner. Element-wise multiplication and sum = -1.
- Normalization: \( -1 / 9 \approx -0.11 \). This value is placed in the feature map.
- Stride Example: A stride of 1 means moving the kernel 1 pixel at a time. A stride of 2 means moving 2 pixels.
- Feature Map Interpretation: For the digit '9', the largest value in the feature map corresponded roughly to the location of the loopy pattern (top-middle).
- Pooling Example:
- Input feature map region (2x2): \( \begin{bmatrix} 5 & 1 \\ 8 & 2 \end{bmatrix} \).
- Max Pooling with stride 2: Output = \( \max(5, 1, 8, 2) = 8 \).
- Next region: \( \begin{bmatrix} 3 & 4 \\ 9 & 2 \end{bmatrix} \). Output = \( \max(3, 4, 9, 2) = 9 \).
Questions asked in class
- Q: How many neurons in the input layer for a 5x5 image?
- A: 25 neurons (plus bias).
- Q: Why is stride not a big number?
- A: A smaller stride (e.g., 1) allows the model to examine the image slowly and in detail, improving understanding. A large stride would skip portions, reducing detail.
- Q: Can kernel size be as large as the image?
- A: Technically yes, but then convolution would happen only once, losing the benefit of scanning the image. Kernel size is typically small (2x2 or 3x3).
- Q: Why normalization in convolution?
- A: To keep values small for easier weight updates and processing.
- Q: Difference between grayscale and black-and-white images?
- A: Grayscale has a range of pixel values (0–255); black-and-white has only 0 or 1.
- Q: Are kernel values predefined?
- A: No, they are weights initialized randomly and learned during training.
- Q: If the image is '7' and a loopy-pattern kernel is applied, how will the feature map look?
- A: It will have values around 0 because there is no loopy pattern to detect.
- Q: Who defines the filters?
- A: Filters are not predefined. They are initialized with random values and learned automatically during training through weight updates.
- Q: How many filters are needed to detect a complete number like '9'?
- A: Many filters are needed; three filters are just an example.
- Q: What is the benefit of pooling?
- A: It reduces the image size (downsamples), lessening detail to prevent over-learning and manage computational load.
- Q: How to choose between max pooling and average pooling?
- A: It is problem-dependent and determined through hyper-parameter tuning (hit and try).
- Q: Does CNN performance depend on the object's location in the image?
- A: No, CNNs are not sensitive to object location; filters detect patterns wherever they appear.
Key takeaways
- ANNs are impractical for large images due to a parameter explosion (e.g., billions of weights) and fail if object location changes.
- CNNs solve this via convolution: using small, sliding kernels to detect local features efficiently.
- The convolution operation involves element-wise multiplication of a kernel with an image patch, summing, and often normalizing the result.
- Stride controls how many pixels the kernel moves; a smaller stride captures more detail.
- Kernels (filters) are not predefined; their weights are initialized randomly and learned during training to detect specific features.
- The ReLU activation function sets negative values to zero, creating cleaner, sparser feature maps.
- Pooling (max or average) downsamples feature maps, reducing computational load and providing translation invariance.
- CNNs learn features hierarchically: from simple edges to complex objects, automatically during training.
- A trained kernel can be reused on any image to detect the feature it learned.
- CNNs are invariant to the location of objects within an image.
- Image augmentation (rotation, scaling) improves model robustness by increasing dataset variety.
- The choice of pooling type and other hyperparameters is determined through experimentation (hyper-parameter tuning).
Exam-style questions
1. Question: For a 1920x1080 RGB image, calculate the number of input neurons required for an ANN. Explain why this is problematic and how a CNN addresses this issue.
- Answer Outline: Number of neurons = \(1920 \times 1080 \times 3 \approx 6.22 \text{ million}\). This leads to a parameter explosion with even a small hidden layer (e.g., 24M weights for 4 hidden neurons), making training slow and prone to overfitting. CNNs address this by using parameter-sharing via small convolutional kernels that scan the image, drastically reducing the number of unique weights.
2. Question: Perform a single step of the convolution operation. Given a 3x3 input patch \( I = \begin{bmatrix} 2 & 4 & 1 \\ 0 & 3 & 5 \\ 2 & 1 & 2 \end{bmatrix} \) and a 3x3 kernel \( K = \begin{bmatrix} 1 & 0 & -1 \\ 1 & 0 & -1 \\ 1 & 0 & -1 \end{bmatrix} \), calculate the output value. Then, apply the ReLU function to this value.
- Answer Outline: Compute element-wise multiplication: \(2\*1 + 4\0 + 1\(-1) + 0\*1 + 3\0 + 5\(-1) + 2\*1 + 1\0 + 2\(-1) = 2 + 0 -1 + 0 + 0 -5 + 2 + 0 -2 = -4\). Output = -4. After ReLU: \( \max(0, -4) = 0 \).
3. Question: Describe the purpose of pooling in a CNN. Compare max pooling and average pooling using a 2x2 example with values [8, 3; 1, 6] and a stride of 2.
- Answer Outline: Pooling reduces the spatial dimensions of feature maps, decreasing computational cost, providing translation invariance, and helping prevent overfitting. For the given region: Max pooling outputs \( \max(8, 3, 1, 6) = 8 \). Average pooling outputs \( (8+3+1+6) / 4 = 4.5 \). Max pooling retains the strongest activation, while average pooling provides a smoothed output.
Glossary
- ANN (Artificial Neural Network) - A conventional neural network that requires manual feature engineering.
- CNN (Convolutional Neural Network) - A neural network architecture designed for automatic feature extraction from grid-like data (e.g., images).
- Convolution - A mathematical operation involving element-wise multiplication and summation of a kernel with input patches.
- Kernel/Filter - A small matrix of weights used in convolution to detect specific features.
- Feature Map - The output matrix from a convolution operation, indicating detected feature locations.
- Stride - The number of pixels a kernel moves during convolution or pooling.
- Pooling - A down-sampling operation (e.g., max, average) that reduces feature map size.
- ReLU - A common activation function that outputs zero for negative inputs and the input itself for positive inputs.
- Hierarchical Feature Learning - The process by which CNNs build complex features from simpler ones across layers.
- MNIST - A dataset of 70,000 handwritten digit images (28x28 grayscale).
- Image Augmentation - Techniques like rotation and scaling applied to training data to improve model generalization.
Follow-ups
- Detailed discussion on padding, specific types of pooling, the ReLU function, flattening, and classification layers were mentioned but not covered in detail.
- Specific CNN architectures like ResNet, MobileNet, ImageNet, .NET, and YOLO were noted as advanced models for self-study.
- How multiple kernels work together to detect different features will be explored further.
- Practical design choices: number of convolution/pooling layers, kernel size, and stride selection.
- Optimization techniques (grid search, random search) and detailed hyper-parameter tuning may be covered in future semesters.
- Recurrent Neural Networks (RNNs) will be covered in the next class.
- A student named Asis might cover time series/sequential models in a future class.
Exam verification — corrections & additions
- Number of filters = depth of the output volume. If a convolution layer has n filters, the resulting feature maps stack into n channels, so increasing the number of filters increases the feature-map depth. Spatial width/height are set by kernel size and stride, not by the number of filters.
- Kernel = filter = feature detector — the same small weight matrix that slides over the image and detects a pattern.
- Pooling reduces the spatial dimensions (down-sampling); it does not change depth.
- ReLU is the standard activation inside CNN convolution blocks.
- Full 80-question answer key:
C:\PORJECTX\aml-import\AML-FINAL-EXAM-ANSWER-KEY.md