session: "6103-advanced-ml/2026-10-03 0926 Advance Machine Learning"
title: "Advance Machine Learning"
date: "2026-10-03 09:26"
duration: "1h 20m"
language: "en"
model: "deepseek-ai/DeepSeek-V3.2"
parts: 3
transcript_chars: 56667
generated: "2026-11-23T02:01:52+05:30"
Advanced Machine Learning
Overview
This class introduced foundational concepts of deep learning, transitioning from traditional machine learning models like linear and logistic regression. It covered the perceptron as the simplest neural network unit, explaining the processes of forward and backward propagation within a single-layer network. The lecture detailed the structure of a simple neural network, the role of activation functions in introducing non-linearity, and the definition of error functions. It also discussed training mechanics like epochs, gradient descent for weight updates, and practical stopping criteria, setting the stage for practical implementation with libraries like Keras.
Learning outcomes
- Explain the structure and function of a perceptron as a basic neural network unit.
- Describe and differentiate between forward propagation and backpropagation.
- Calculate the output of a simple neural network given inputs, weights, and an activation function.
- Define common cost functions like Mean Squared Error and explain their use.
- Apply the gradient descent weight update rule using derivatives obtained via the chain rule.
- Identify the role of hyperparameters like learning rate and the purpose of techniques like dropout and early stopping.
Core concepts
Perceptron/Neuron
A perceptron is a single neuron, representing the basic computational unit of a neural network. It performs a linear combination of inputs and weights, followed by an activation function. This matters because it is the fundamental building block from which all neural networks are constructed, connecting to layers and the overall network architecture.
Forward Propagation
Forward propagation is the process of calculating the network's output by passing input data through successive layers, applying linear combinations and activation functions. It matters because it is the 'prediction' phase that produces the result used to compute the error, connecting directly to the definition of the loss function.
Backward Propagation (Backpropagation)
Backpropagation is the process of updating the network's weights by propagating the error from the output layer back through the network using gradient descent and the chain rule. It matters because it is the mechanism by which the network 'learns' and minimizes error, connecting the cost function to the weight update rules.
Activation Function
An activation function is a non-linear function applied to the linear combination (z) of a neuron's inputs and weights. It matters because it introduces the non-linearity necessary for neural networks to learn complex patterns, and it constrains outputs to specific ranges (e.g., 0 to 1 for sigmoid). It connects the linear computation (z) to the neuron's output (a).
Error / Cost / Loss Function
The error function quantifies the difference between the network's prediction and the actual target value. Specifically, Mean Squared Error was discussed. It matters because it defines the objective that gradient descent aims to minimize, serving as the direct link between the network's output and the weight update process.
Epoch
An epoch is one complete cycle of training where the entire dataset is used for one forward propagation followed by one backward propagation. It matters because it is a fundamental unit for measuring training progress, connecting to concepts like training duration and early stopping criteria.
Gradient Descent
Gradient descent is an optimization algorithm used to update weights by moving them in the direction opposite to the gradient of the cost function. It matters because it is the core algorithm that enables learning in neural networks, connecting the derivative of the loss to the practical update of weights.
Hidden Layer
A hidden layer is a layer of neurons between the input and output layers where feature extraction and transformations occur. It matters because the presence of at least one hidden layer is a key characteristic of deep learning, distinguishing it from simpler models and enabling the learning of hierarchical features.
Formulas and maths
- Linear Combination (General):
z^l = θ^{l} a^{l-1} or z = θ x z^l is the linear combination for layer l, θ^{l} are the weights for layer l, a^{l-1} is the activation output from the previous layer (or input x for the first layer).- Used in every layer during forward propagation to compute the input to the activation function.
- Activation Function Application:
a^l = g(z^l) a^l is the activation output of layer l, g() is the activation function (e.g., sigmoid).- Used after every linear combination to introduce non-linearity and produce the layer's output.
- Mean Squared Error (Cost Function):
J(θ) = 1/2 * (y_{actual} - a^3)^2 J(θ) is the cost, y_{actual} is the true value, a^3 is the final network output (activation of output layer).- Used as a loss function for regression problems to quantify prediction error.
- Gradient Descent Weight Update Rule:
θ_{new} = θ_{old} - \eta * (\partial J(θ) / \partial θ_{old}) θ_{new} is the updated weight, θ_{old} is the current weight, \eta is the learning rate, \partial J(θ) / \partial θ_{old} is the gradient of the cost with respect to the weight.- Used during backpropagation in every epoch to iteratively reduce the cost.
- Backpropagation Chain Rule (for output layer weight θ2):
\partial J(θ) / \partial θ2 = (\partial J(θ) / \partial a^3) (\partial a^3 / \partial z^3) (\partial z^3 / \partial θ2) - This breaks down the gradient for a weight connecting the hidden layer to the output layer.
- Used to calculate the precise gradient for updating weights in the output layer.
- Backpropagation Chain Rule (for hidden layer weight θ1):
\partial J(θ) / \partial θ1 = (\partial J(θ) / \partial a^3) (\partial a^3 / \partial z^3) (\partial z^3 / \partial a^2) (\partial a^2 / \partial z^2) (\partial z^2 / \partial θ1) - This breaks down the gradient for a weight connecting the input layer to the hidden layer.
- Used to calculate the precise gradient for updating weights in the hidden layer(s), demonstrating how error propagates backward.
Worked examples
- Epoch Progression: Accuracy values over epochs were given as examples: first epoch accuracy 0.80, second epoch 0.78, another example showed 0.81.
- Learning Rate Example: A default learning rate of
0.001 was mentioned as a common starting value. - Multi-class Classification Output: An example with three classes (dog, cat, giraffe) showed model output probabilities: 0.2 (dog), 0.3 (cat), 0.5 (giraffe). The class with the highest probability (giraffe) is the prediction.
- Network Scale Example: Real-world input dimensions can be 1024 or 512. Hidden layers can have 64, 512, 128, 1024, or 2048 neurons, decided through hyperparameter tuning.
- Error Calculation Example: Desired output = 1, actual network output = 0.7, therefore error = 0.3.
- Dropout Example: Applying 25% dropout means during training, 25% of random neurons in a layer are ignored (dropped), and only 75% are active.
- Training Plateau Example: Accuracy increases from 89% (epoch 1) to 98% (epoch 10), then plateaus, indicating a potential point for early stopping.
Questions asked in class
- Q: Can we have multiple types of activation functions in a single layer?
- A: No. In a single layer, we apply a single activation function for all neurons.
- Q: How do weights and activation functions work together in forward propagation?
- A: Sequence: input
x multiplied by weight θ1, apply activation g to get hidden output a2, multiply a2 by weight θ2, apply activation g to get final output a3. - Q: When and how does the neural network actually learn?
- A: Learning happens during backpropagation, where weights are updated using the error from the forward pass.
- Q: Are perceptrons only hidden neurons?
- A: No, perceptron refers to a neuron. All circles (input, hidden, output) are kinds of perceptrons.
- Q: What is an epoch?
- A: One cycle of training, including one forward and one backward propagation through the entire dataset.
- Q: How is Machine Learning (ML) different from Deep Learning (DL)?
- A: In ML, feature extraction uses separate methods. In DL, feature extraction happens inside the neurons of the neural network.
- Q: If a non-linear activation output is multiplied by a weight, how does it become a linear combination?
- A: The activation output (e.g., 0 to 1) is treated as the input to the next layer. Multiplying it by a weight again produces a linear combination for that new layer. The operation of weight multiplication is linear.
- Q: Can we have more than one activation function in a layer with multiple neurons?
- A: Yes, each neuron in a layer has its own activation function. In a single layer with multiple neurons, there are multiple activation functions (though they are often the same type for simplicity).
- Q: How do we decide the number of hidden layers/neurons?
- A: It's a hit-and-trial method (e.g., start with 64, then 128, etc.). The engineer/user decides through hyperparameter tuning.
- Q: When accuracy plateaus at 98%, should we look for early stopping?
- A: Yes, 100%. Early stopping can be used when accuracy stagnates across epochs to reduce computational complexity.
Key takeaways
- A perceptron is a single neuron and the basic unit of a neural network; input, hidden, and output units are all perceptrons.
- Forward propagation computes the network's output via sequential linear combinations and activation functions.
- Learning occurs during backpropagation, where weights are updated using gradient descent to minimize the cost function.
- An activation function (e.g., sigmoid) introduces necessary non-linearity; all neurons in a single layer typically use the same function.
- One complete forward pass and backward pass through the entire dataset constitutes one epoch.
- The Mean Squared Error,
J(θ) = 1/2 * (y - a3)^2, is a common cost function for regression. - Weight update follows the rule:
θ_new = θ_old - learning_rate * (∂J/∂θ_old), using gradients calculated via the chain rule. - The number of hidden layers and neurons is a hyperparameter decided by the practitioner through experimentation (e.g., trying 64, 128, 512 neurons).
- Dropout randomly ignores a percentage of neurons during training to prevent overfitting.
- Early stopping halts training when validation performance plateaus to save computational resources.
- In deep learning, feature extraction is performed internally by the network's neurons, unlike in traditional ML where it is often a separate step.
- For multi-class classification, the output layer has multiple neurons, and the class with the highest activation probability is the prediction.
Exam-style questions
1. Describe the steps of forward propagation in a simple neural network with one input, one hidden, and one output neuron. Include the formulas for linear combination and activation.
- Outline: Start with input
x. Calculate z2 = θ1 x. Apply activation: a2 = g(z2). Calculate z3 = θ2 a2. Apply activation: a3 = g(z3). a3 is the final prediction.
2. Explain the purpose of backpropagation and write the chain rule used to calculate the gradient for a weight in the hidden layer (θ1).
- Outline: Purpose: To update weights by propagating error backward to minimize the cost function. Chain rule:
∂J/∂θ1 = (∂J/∂a3) (∂a3/∂z3) (∂z3/∂a2) (∂a2/∂z2) (∂z2/∂θ1).
3. A neural network for binary classification uses a single output neuron with a sigmoid activation. If the true label is 1 and the network outputs 0.7, what is the squared error? If the learning rate is 0.01 and the gradient ∂J/∂θ for a weight is calculated as -0.5, what is the new weight value if the old weight was 0.4?
- Outline: Squared error:
J = 1/2 (1 - 0.7)^2 = 0.045. New weight: θ_new = 0.4 - 0.01 (-0.5) = 0.4 + 0.005 = 0.405.
4. Compare and contrast the concepts of dropout and early stopping. When would you consider using each technique?
- Outline: Dropout: A regularization technique applied during training to prevent overfitting by randomly dropping neurons. Use when the model overfits (high train accuracy, low test accuracy). Early stopping: A criterion to halt training when validation performance stops improving. Use to reduce unnecessary computation after accuracy plateaus.
5. In the context of a fully connected neural network, who decides the number of neurons in the hidden layers, and what is a common practical approach for deciding this?
- Outline: The machine learning engineer/user decides. Common approach: Hyperparameter tuning via hit-and-trial, e.g., experimenting with values like 64, 128, 512, 1024 and selecting based on validation performance.
Glossary
- Perceptron - A single neuron, the basic processing unit in a neural network.
- Forward Propagation - The process of computing an output from input data by passing it through network layers.
- Backpropagation - The algorithm for updating network weights by propagating the error gradient backward.
- Activation Function - A non-linear function applied to a neuron's output to introduce complexity into the model.
- Epoch - One complete pass of forward and backward propagation through the entire training dataset.
- Gradient Descent - An optimization algorithm that iteratively adjusts parameters to minimize a cost function.
- Hidden Layer - An internal layer of a neural network between input and output layers.
- Cost/Loss Function - A function that measures the discrepancy between predicted and actual values.
- Learning Rate - A hyperparameter controlling the step size of weight updates in gradient descent.
- Dropout - A regularization technique where random neurons are ignored during training to prevent overfitting.
- Early Stopping - A method to terminate training when model performance on a validation set stops improving.
- Overfitting - When a model learns training data patterns too well, including noise, harming its performance on new data.
Follow-ups
- Detailed coding implementation of neural networks is promised for the next class.
- Multi-layer perceptron examples and detailed backpropagation calculations will be covered in upcoming classes.
- Base normalization was mentioned but not discussed; the instructor will cover it in an upcoming class.
- The decisions an ML engineer needs to make to design a model will become clearer once the syllabus is completed.
- A detailed discussion on early stopping or callback methods for stopping training was noted but not elaborated.
Exam verification — corrections & additions
- Gradient of the squared loss. With J = ½(wᵀx + b − t)² and y = wᵀx + b:
- ∂J/∂w = (y − t)·x
- ∂J/∂b = (y − t)
- One gradient-descent step: w ← w − η(y − t)x and b ← b − η(y − t).
Example: x = [2,1], t = 1, w = [0,0], b = 0, η = 0.1 → y = 0, (y − t) = −1 → w = [0.2, 0.1], b = 0.1.
- Decision boundary: wᵀx + b = 0. Example: 2x₁ + 3x₂ − 6 = 0 → w = [2, 3], b = −6.
- Full 80-question answer key:
C:\PORJECTX\aml-import\AML-FINAL-EXAM-ANSWER-KEY.md