ISP560 Notes
ISP560 Notes
06 – Backpropagation Neural
Network
Mohd Razif Shamsuddin
0193371231
Machine Learning:
Backpropagation Neural Network
Mohd Razif Shamsuddin :: Faculty of Computer Science & Mathematics
Backpropagation
Backpropagation Neural Network as an Extension of Linear Regression and Perceptron
6.1 Introduction: From Linear Regression to Backpropagation
• Linear Regression:
• In linear regression, the relationship between input features and the target variable is modeled as a
linear equation, where the weights are adjusted to minimize the error.
• Limitations: Linear regression can only model linear relationships and is limited to a single output,
making it unsuitable for more complex tasks.
• Perceptron:
• The perceptron is a simple neural network unit that uses linear functions and applies an activation
function to decide whether to activate the neuron. However, it can only solve linearly separable
problems.
• Backpropagation Neural Network:
• Backpropagation is an extension of both linear regression and perceptrons. It is a multi-layered neural
network where the model can learn non-linear relationships through multiple hidden layers and
activation functions.
• The core idea of backpropagation is to adjust the weights in each layer of the network based on the
error (similar to how gradient descent is used in linear regression).
What is Backpropagation Neural Network?
• Backpropagation: Backward Propagation of Errors
• It is a multilayer neural network and a standard
method of training artificial neural networks.
• This method helps to calculate the gradient of a loss
function with respects to all the weights in the
network.
• It is the method of fine-tuning the weights of a neural
net based on the error rate obtained in the previous
epoch
• Proper tuning of the weights allows you to reduce
error rates and to make the model reliable by
increasing its generalization
..cont
Why BPNN?
• Backpropagation is fast, simple and easy to program
• It has no parameters to tune apart from the numbers of input
• It is a flexible method as it does not require prior knowledge
about the network
• It is a standard method that generally works well
• It does not need any special mention of the features of the
function to be learned.
2
3
4
How it works?
Important Key Points:
• Simplifies the network structure by elements weighted links that
have the least effect on the trained network
• Although a single-layer net is severely limited in the mappings it
can learn, a multilayer net (with one or more hidden layers) can
learn any continuous map- ping to an arbitrary accuracy. More than
one hidden layer may be beneficial for some applications, but one
hidden layer is sufficient. (Fausette, 1990 pg 290)
• Need to study a group of input and activation values to develop the
relationship between the input and hidden unit layers.
• It helps to assess the impact that a given input variable has on a
network output and the knowledge gained from this analysis should
be represented in rules.
• Backpropagation is especially useful for deep neural networks
working on error-prone projects, such as image or speech
recognition.
Disadvantage of BPNN
• The actual performance of backpropagation on a
specific problem is dependent on the input data.
• Backpropagation can be quite sensitive to noisy data
• Need to use the matrix-based approach for
backpropagation instead of mini-batch.
References:
• Fausett Book
• Artificial Intelligence Book by Rob Callan
• https://www.guru99.com/backpropogation-neural-network.html
• https://wp.wwu.edu/machinelearning/2017/01/22/generalization-and-
overfitting/
• Negnevitsky: Introduction to Artificial Intelligence
• Previous Lecture Notes iTS660
Exercises:
MACHINE LEARNING
REVISION Week 7
What have we learn so far?
• 20/11/2023
By now you should know what is Machine Learning:
-In essence, machine learning is about (1)enabling computers to learn
from experience and (2)make intelligent decisions or predictions based
on that learning, (3)without being explicitly programmed for each task.
-its about mathematics and science and it’s a subfield of A.I.
What have we learn so far?
Why should we learn about Machine Learning & what is its applications in
the real world?
Why? (1) Automation and Efficiency, (2) Solving Complex Problems, (3)Career
Opportunities, (4) Competitive Edge, (5) Pattern, Predictive, Behavioral
Analytics, (6) Research Opportunity
Application:
- Medical Field (Diagnosis)
- Digital Imaging
- Predictive analysis
- Data Analytics
What we have learn so far?
What are the similarities of ANN and BNN?
- Neurons/Nodes : both have input and output.
- Connections/Edges : connects the neurons
- Learning mechanism: how to update weights
- Activation of neuron: how signals are transmitted through the
network
What are the available Machine Learning
Algorithm.
• Algorithm = step by step processes
• Model = trained algorithm
• Architecture = the structure of the ANN
2
Hebbian Neural Network
4
Exercise
Hebbian Neural Network
Probe
Hebbian Neural Network
8.3 Strengths of Hebbian Networks
Unsupervised Learning: Hebbian networks learn in an unsupervised manner,
making them highly useful for situations where labeled data is scarce or
unavailable. They are designed to find patterns and relationships within data by
strengthening neuron connections that activate together frequently.
• Definition 3 (Wikipedia):
"Machine learning is the study of computer algorithms that improve automatically through experience and by the use of
data."
Explanation: This definition highlights the autonomy of ML algorithms in evolving based on their exposure to data.
Introduction to Machine Learning
1.3 Key Components of Machine Learning:
• Data: The fuel for machine learning models, consisting of historical
records, images, or any form of information the algorithm can process.
• Algorithms: Mathematical models designed to process data, recognize
patterns, and make predictions.
• Experience (Training): The process of feeding data to algorithms to
allow them to learn patterns and adjust their predictions based on
feedback.
• Learning: The algorithm's ability to improve its performance over time
as it is exposed to more data.
Introduction to Machine Learning
1.4 How Machine Learning Generally Works:
• Step 1: Data Collection – Gather historical or real-time data for the task.
• Step 2: Data Preprocessing – Clean and prepare the data to ensure the model
can use it effectively.
• Step 3: Model Selection – Choose the right algorithm (e.g., decision trees,
neural networks).
• Step 4: Training – Feed the data into the model to teach it the patterns and
relationships.
• Step 5: Testing – Evaluate how well the model performs on new, unseen data.
• Step 6: Deployment – Use the trained model to make predictions or
automate tasks in real-world applications.
Introduction to Machine Learning
1.5 Real-World Applications of Machine Learning:
• Healthcare: Predicting patient outcomes, drug discovery,
diagnosing diseases.
• Finance: Fraud detection, algorithmic trading, risk assessment.
• Retail: Personalized recommendations, dynamic pricing, demand
forecasting.
• Technology: Speech recognition (e.g., Siri, Google Assistant), self-
driving cars, facial recognition systems.
Introduction to Machine Learning
1.6 Importance of Machine Learning:
• Efficiency: Automates complex and repetitive tasks.
• Scalability: Can handle large datasets and make accurate
predictions without human intervention.
• Adaptability: Continuously improves as more data becomes
available.
• Decision-making: Helps businesses and systems make data-
driven decisions that improve performance and outcomes.
02 - Types of Machine Learning
Mohd Razif Shamsuddin :: Faculty of Computer Science & Mathematics
Types of Machine Learning
2.1 Supervised Learning
• Definition: Supervised learning involves training a model on a
labeled dataset, where the input data is paired with the correct
output. The model learns to map inputs to the correct outputs by
minimizing the error between its predictions and the actual labels.
• How it Works:
• Training: The model is fed with input-output pairs (features and labels). It
learns a function that maps inputs to outputs by adjusting its parameters
to minimize prediction errors.
• Testing: After training, the model is tested on new data (input features) to
predict outputs.
Types of Machine Learning
2.1 Supervised Learning
Example:
Image Classification: A dataset of images (input) is labeled with the
objects in the images (output). The model learns to classify new, unseen
images based on the patterns it has learned.
Spam Detection: Models are trained on labeled emails (spam or not
spam) and can automatically filter emails.
Predictive Maintenance: In industrial settings, data on equipment
performance (e.g., temperature, vibration) is used to predict equipment
failure.
Medical Diagnosis: Given patient data (input features like symptoms,
test results), the model predicts the presence or absence of a disease.
Types of Machine Learning
2.2 Unsupervised Learning
• Definition: Unsupervised learning works with data that is not
labeled. The model explores the structure of the data, identifying
patterns, groups, or associations within the dataset without
predefined labels.
• How it Works:
• Clustering: The model groups similar data points together based on
certain features.
• Dimensionality Reduction: The model reduces the number of variables
in the data while retaining important information, helping to visualize or
speed up data processing.
Types of Machine Learning
2.2 Unsupervised Learning
Example:
Customer Segmentation: A retail company uses purchase data to group
customers into segments based on behavior, preferences, and
purchasing habits without knowing the labels upfront.
Market Segmentation: Grouping customers into distinct segments for
targeted marketing.
Anomaly Detection: Identifying abnormal patterns in network traffic,
financial transactions, or sensor data to detect fraud or system failures.
Recommender Systems: Clustering users based on their viewing habits
to recommend personalized content on platforms like Netflix or YouTube.
Types of Machine Learning
2.3 Reinforcement Learning
• Definition: Reinforcement learning involves an agent learning to
make decisions by interacting with an environment. The agent
takes actions and receives feedback in the form of rewards or
penalties, learning from this feedback over time.
• How it Works:
• Agent: The decision-making entity.
• Environment: The context or system with which the agent interacts.
• Reward: Feedback given to the agent to reinforce good decisions or
penalize bad decisions.
• Goal: Maximize cumulative rewards over time.
Types of Machine Learning
2.3 Reinforcement Learning
Example:
Game AI: An AI agent learns to play chess by playing games and receiving
feedback (win, lose, or draw) after each game. It improves its strategy by
maximizing its chances of winning.
Autonomous Vehicles: A self-driving car learns to navigate through traffic by
taking actions (steering, accelerating) and receiving rewards based on how well
it avoids obstacles or follows traffic rules.
Robotics: Robots learn to perform tasks like assembling parts or walking by
interacting with their environment and adjusting their actions based on
feedback.
Personalized Marketing: E-commerce platforms use reinforcement learning
to optimize product recommendations by learning which items result in
purchases (reward) or customer disinterest (penalty).
Exercise : Give your own example of ML
applications
• How it Works:
• Training: The model is fed with input-output pairs (features and labels).
It learns a function that maps inputs to outputs by adjusting its
parameters to minimize prediction errors.
• Testing: After training, the model is tested on new data (input features)
to predict outputs.
Supervised Learning Algorithm
Supervised Learning (Cont.)
Example:
• Image Classification: A dataset of images (input) is labeled with the objects in
the images (output). The model learns to classify new, unseen images based on
the patterns it has learned.
• Spam Detection: Models are trained on labeled emails (spam or not spam) and
can automatically filter emails.
• Predictive Maintenance: In industrial settings, data on equipment performance
(e.g., temperature, vibration) is used to predict equipment failure.
• Medical Diagnosis: Given patient data (input features like symptoms, test
results), the model predicts the presence or absence of a disease.
04 – Linear Regression
Mohd Razif Shamsuddin :: Faculty of Computer Science & Mathematics
Linear Regression
• 4.1 Introduction to Regression
• What is Regression?
Regression is a fundamental concept in supervised learning,
where the goal is to predict a continuous outcome (dependent
variable) based on one or more input features (independent
variables).
• Linear Regression: The simplest form of regression, where the
relationship between the input and output is modeled as a straight line.
Linear Regression
Linear Regression (Cont.)
Linear Regression (Cont.)
Linear Regression (Cont.)
Linear Regression (Cont.)
Linear Regression Exercise
Linear Regression Exercise (Cont.)
1
2
Linear Regression Exercise (Cont.)
3
4
Linear Regression
• 4.5 Visualization of Linear Regression
• Scatter Plot: A scatter plot of the data points (size vs. price) with
the regression line superimposed.
• The line represents the best-fit line that minimizes the cost function.
• Gradient Descent Visualization: A plot showing the cost
function's surface and how the weights are adjusted during each
iteration of gradient descent, moving toward the minimum.
Linear Regression
• 4.6 Conclusion
• Why Linear Regression?: Linear regression is simple,
interpretable, and often a good starting point for many machine
learning problems, especially when the relationship between the
features and the target is linear.
• Limitations: Linear regression is limited when the relationship
between the input and output is nonlinear or when there are
complex interactions between features.
05 – Perceptron as a simple computing
element
Mohd Razif Shamsuddin :: Faculty of Computer Science & Mathematics
Neuron as a simple computing element
• A neuron receives several signals from its input links
• Computes a new activation level and sends it as an output
signal through the output links.
• The input signal can be raw data or outputs of other neurons.
• The output signal can be either a final solution to the problem
or an input to other neurons. Figure below shows a typical
neuron.
Input Neurons
Output Neurons
Activation functions
• What are activation functions?
• Activation function decides, whether a neuron should be
activated or not by calculating weighted sum = x_in and further
adding bias with it. The purpose of the activation function is to
introduce non-linearity into the output of a neuron.
• https://missinglink.ai/guides/neural-network-
concepts/7-types-neural-network-activation-
functions-right/
-1
X1
W1
Activation
Function
W2
X2
Output Neuron
Input Neurons
Perceptron (Step 1: Initialization)
• Step 1:
1
• Initialisation Set initial weights w1, w2, ... wn
• set threshold θ to random numbers in the range between [-0.5 to
0.5].
• Set alpha α value at a low value. Example: 0.1
Perceptron (Step 2: Activation)
• Step 2:
2
• Activate the perceptron by applying inputs X1, X2, ... Xn and
desired output Y1.
• Calculate the actual output at iteration p = 1
• Can perceptron
learn
• XOR operation?
• Why not?
Linearly and non-linearly separable function
Linearly and non-linearly separable function