Artificial Intelligence · Unit 8
Machine Learning and Neural Networks
Exam-focused notes for Machine Learning and Neural Networks (Artificial Intelligence, BIT252): what the TU syllabus asks and how it has actually been tested, with 7 solved past questions from this unit.
Machine Learning and Neural Networks in short
Machine learning lets a program improve from data instead of fixed rules. This chapter covers the idea of learning, and the artificial neural network, which is a main learning model inspired by the brain.
What this unit covers
- Machine learning definition
- Artificial neural network mathematical model
- Neuron structure and activation functions
- Feed-forward neural networks
- Recurrent neural networks
- Back-propagation algorithm
- Learning rules and learning rates
- Neural network types and architectures
Back-propagation algorithm
2082 · 10 marks
What is learning rule?How learning is done in ANN using back propagation algorithm?[2+8]
Show solved answerHide answer
Learning Rule and Backpropagation in ANN
Part 1: What is a Learning Rule? [2 marks]
A learning rule is a method or procedure that modifies the weights and biases of a neural network in order to improve its performance on a given task. It defines how the network learns from training data by updating connection weights based on the error between the actual output and the desired output.
Common types of learning rules include:
- Hebbian Learning Rule - weights are updated based on the correlation of input and output activations
- Perceptron Learning Rule - weights are updated when the output is incorrect
- Delta (Widrow-Hoff) Rule - weights are updated proportional to the error
- Backpropagation Rule - generalized delta rule for multilayer networks
General form: $$\Delta w_{ij} = \eta \cdot \delta_j \cdot x_i$$ where $\eta$ is the learning rate, $\delta_j$ is the error signal, and $x_i$ is the input.
Part 2: Learning Using Backpropagation Algorithm [8 marks]
Overview
Backpropagation (BP) is a supervised learning algorithm used to train multilayer feedforward neural networks. It works by:
- Forward pass - computing the output
- Backward pass - propagating the error backward and updating weights
Network Architecture
Consider a three-layer network:
- Input layer - nodes indexed $i$
- Hidden layer - nodes indexed $j$
- Output layer - nodes indexed $k$
Step-by-Step Backpropagation Algorithm
Step 1: Initialize Weights
Set all weights $w_{ij}$ and $w_{jk}$ to small random values (typically between -0.5 and 0.5).
Step 2: Forward Pass (Feed Forward)
At the hidden layer, compute the net input and activation for each hidden neuron $j$:
$$net_j = \sum_i w_{ij} \cdot x_i + b_j$$
$$y_j = f(net_j) = \frac{1}{1 + e^{-net_j}} \quad \text{(sigmoid activation)}$$
At the output layer, compute the net input and activation for each output neuron $k$:
$$net_k = \sum_j w_{jk} \cdot y_j + b_k$$
$$o_k = f(net_k) = \frac{1}{1 + e^{-net_k}}$$
Step 3: Compute Output Error
For each output neuron $k$, compute the error signal $\delta_k$:
$$E = \frac{1}{2} \sum_k (t_k - o_k)^2$$
where $t_k$ is the target (desired) output and $o_k$ is the actual output.
The error gradient at the output layer:
$$\delta_k = (t_k - o_k) \cdot f'(net_k)$$
For sigmoid activation: $f'(net_k) = o_k(1 - o_k)$
$$\boxed{\delta_k = (t_k - o_k) \cdot o_k(1 - o_k)}$$
Step 4: Backpropagate Error to Hidden Layer
Compute the error signal $\delta_j$ for each hidden neuron $j$:
$$\delta_j = \left(\sum_k \delta_k \cdot w_{jk}\right) \cdot f'(net_j)$$
$$\boxed{\delta_j = \left(\sum_k \delta_k \cdot w_{jk}\right) \cdot y_j(1 - y_j)}$$
The error is propagated backward from output to hidden layer using the weights.
Step 5: Update Weights
Update weights between hidden and output layer:
$$\Delta w_{jk} = \eta \cdot \delta_k \cdot y_j$$
$$w_{jk}^{new} = w_{jk}^{old} + \Delta w_{jk}$$
Update weights between input and hidden layer:
$$\Delta w_{ij} = \eta \cdot \delta_j \cdot x_i$$
$$w_{ij}^{new} = w_{ij}^{old} + \Delta w_{ij}$$
where $\eta$ is the learning rate (typically 0.01 to 0.9).
Step 6: Repeat
Repeat Steps 2 to 5 for all training patterns until the total error $E$ is minimized below a threshold or the maximum number of epochs is reached.
Summary Diagram
Input Layer Hidden Layer Output Layer
x_i ---w_ij---> y_j ---w_jk---> o_k
|
Error = (t_k - o_k)
|
<--- delta_j <--- delta_k (backpropagated)
Weight update Weight update
Key Points
| Aspect | Detail |
|---|---|
| Type | Supervised learning |
| Direction | Forward (compute output) + Backward (update weights) |
| Activation | Sigmoid (differentiable) |
| Error function | Mean Squared Error (MSE) |
| Weight update | Gradient Descent |
| Learning rate $\eta$ | Controls step size of weight update |
Advantages and Limitations
Advantages:
- Can learn complex nonlinear mappings
- Works for multilayer networks
Limitations:
- May get stuck in local minima
- Slow convergence for large networks
- Requires labeled training data
- Sensitive to learning rate choice
0 · 10 marks
Why do we need recurrent neural network? How does back propagation learn to minimize the error? Explain[10]
Artificial neural network mathematical model
2082 · 5 marks
Describe the mathematical model of ANN. Differentiate feed-forward ANN from feed-back ANN. [2+3]
2080.2 · 10 marks
Express the mathematical model of a neuron. Distinguish between learning rule and learning rate. How Back-propagation algorithm is used in learning? Explain.[10]
Show solved answerHide answer
Mathematical Model of a Neuron, Learning Rule vs Learning Rate, and Back-Propagation Algorithm
Note: No specific curriculum notes were provided for this question. The answer below is based on standard, correct Artificial Neural Networks (ANN) theory as taught in BSc CSIT Neural Networks / AI courses.
1. Mathematical Model of a Neuron (McCulloch-Pitts Model)
A biological neuron is mathematically modelled as a processing unit that receives multiple inputs, weights them, sums them, and passes the result through an activation function.
Structure
x1 --w1--|
x2 --w2--|
x3 --w3--|--> [Σ Weighted Sum] --> [Activation f] --> Output y
... |
xn --wn--|
|
bias (b)
Mathematical Expression
Step 1: Weighted Sum (Net Input)
$$net = \sum_{i=1}^{n} w_i x_i + b$$
Where:
- $x_i$ = input signals ($x_1, x_2, \ldots, x_n$)
- $w_i$ = synaptic weights corresponding to each input
- $b$ = bias term (threshold)
- $net$ = net activation value
Step 2: Activation Function
$$y = f(net) = f\left(\sum_{i=1}^{n} w_i x_i + b\right)$$
Where $f(\cdot)$ is the activation function. Common choices:
| Activation Function | Formula |
|---|---|
| Step / Threshold | $f(net) = 1$ if $net \geq \theta$, else $0$ |
| Sigmoid | $f(net) = \dfrac{1}{1+e^{-net}}$ |
| Tanh | $f(net) = \tanh(net)$ |
| ReLU | $f(net) = \max(0, net)$ |
Vector Form
$$y = f(\mathbf{w}^T \mathbf{x} + b)$$
Where $\mathbf{w} = [w_1, w_2, \ldots, w_n]^T$ and $\mathbf{x} = [x_1, x_2, \ldots, x_n]^T$.
2. Distinction Between Learning Rule and Learning Rate
| Aspect | Learning Rule | Learning Rate |
|---|---|---|
| Definition | A mathematical procedure or algorithm that specifies how the weights of a neural network are updated during training | A scalar hyperparameter ($\alpha$ or $\eta$) that controls the size of the weight update step |
| Nature | A qualitative strategy / algorithm | A quantitative numerical value |
| Purpose | Defines the direction and method of weight adjustment | Controls the magnitude of weight adjustment |
| Examples | Hebbian rule, Perceptron rule, Delta rule, Backpropagation, Competitive learning | $\eta = 0.01$, $\eta = 0.1$, $\eta = 0.5$ |
| Effect if wrong | Wrong rule leads to incorrect convergence or divergence | Too large $\eta$: oscillation/divergence; Too small $\eta$: very slow convergence |
| Formula role | Determines the form of $\Delta w$ | Scales the update: $\Delta w = \eta \cdot \delta \cdot x$ |
Example (Delta Rule):
$$\Delta w_i = \eta \cdot (t - y) \cdot x_i$$
- Learning rule here is the Delta Rule (error-correction rule)
- Learning rate is $\eta$ (e.g., 0.1)
3. Back-Propagation Algorithm in Learning
What is Back-Propagation?
Back-propagation (BP) is a supervised learning algorithm used to train multi-layer feedforward neural networks (MLPs). It works by propagating the output error backward through the network to compute gradients and update weights using gradient descent.
Network Architecture
Input Layer Hidden Layer Output Layer
x1 ------> h1 ------> o1
x2 ------> h2 ------> o2
x3 ------> h3
Algorithm Steps
Phase 1: Forward Pass
- Present input $\mathbf{x}$ to the network.
- Compute net input and output at each hidden neuron $j$:
$$net_j = \sum_i w_{ij} x_i + b_j, \quad h_j = f(net_j)$$
- Compute net input and output at each output neuron $k$:
$$net_k = \sum_j w_{jk} h_j + b_k, \quad o_k = f(net_k)$$
Phase 2: Compute Output Error
For each output neuron $k$, compute the error:
$$E = \frac{1}{2} \sum_k (t_k - o_k)^2$$
Where $t_k$ is the target (desired) output and $o_k$ is the actual output.
Phase 3: Backward Pass (Error Propagation)
At Output Layer:
Compute error signal (delta) for output neuron $k$:
$$\delta_k = (t_k - o_k) \cdot f'(net_k)$$
For sigmoid: $f'(net_k) = o_k(1 - o_k)$
So: $\delta_k = (t_k - o_k) \cdot o_k(1 - o_k)$
At Hidden Layer:
Propagate error back to hidden neuron $j$:
$$\delta_j = \left(\sum_k \delta_k \cdot w_{jk}\right) \cdot f'(net_j)$$
$$\delta_j = \left(\sum_k \delta_k \cdot w_{jk}\right) \cdot h_j(1 - h_j)$$
Phase 4: Update the Weights
Each weight is adjusted against its own delta and the activation feeding it, where $\eta$ is the learning rate:
$$w_{jk} \leftarrow w_{jk} + \eta \cdot \delta_k \cdot h_j$$
$$w_{ij} \leftarrow w_{ij} + \eta \cdot \delta_j \cdot x_i$$
The forward and backward passes repeat for every training pattern until the total error $E$ falls below the chosen tolerance or the epoch limit is reached.
Neural network types and architectures
Machine learning definition
2080 · 5 marks
What is machine learning? Describe about NLU and NLG. [5]
Neuron structure and activation functions
2079 · 5 marks
What is the task of activation function? What are its types? [5]
Make Unit 8 stick
Practice BIT252 with flashcards & quizzes