You are on page 1of 32

Course Title: Introduction to AI.

Credit Hour: 3 hrs.


ECTS: 5 [2 Lecture hours and 3 Lab hours]
Lecture Schedule: Every _____________

Bedasa Wayessa

Introduction to AI - CoSc3112 1
Machine Learning Basics

Introduction to AI - CoSc3112 2
Outline
 Knowledge in Learning
 Learning Probabilistic Models
 Supervised learning
‒ Linear classification models
‒ Probabilistic models
 Unsupervised learning
‒ Clustering models
 Reinforcement learning
 Deep Learning
‒ Neural networks and back-propagation
‒ Convolution neural networks
‒ Recurrent neural networks and LSTMs

Introduction to AI - CoSc3112 3
Introduction
 An agent is learning if it improves its performance after making
observations about the world.
 When the agent is a computer we call it machine learning.
 a computer observes some data, builds a model based on the data, and
uses the model as both a hypothesis about the world and a piece of
software that can solve problems.
 Why would we want a machine to learn? Why not just program?
 There are two main reasons:
 First, the designers cannot anticipate(expect) all possible future situations.
 Second, sometimes the designers have no idea how to program a solution
themselves.

Introduction to AI - CoSc3112 4
Introduction
 Forms of Learning:
 Any component of an agent program can be improved by machine
learning.
 Learning takes many forms, depending on the nature of the agent,
the component to be improved, and the available feedback.
 The improvements, and the techniques used to make them, depend on these
factors:
 Which component is to be improved.
 What prior knowledge the agent has, which influences the model it builds.
 What data and feedback on that data is available.

Introduction to AI - CoSc3112 5
Introduction
 Forms of Learning:
 Example: Self-driving car agent component to be learned
 Consider a self-driving car agent that learns by observing a human driver.
 Every time the driver brakes, the agent might learn a condition action
rule for when to brake (component 1).
 By seeing many camera images that it is told contain buses, it can learn
to recognize them (component 2).
 By trying actions and observing the results for example, braking hard
on a wet road—it can learn the effects of its actions (component 3).
 little prior knowledge:- it starts from scratch and learns from the data.

Introduction to AI - CoSc3112 6
Introduction to Machine learning
 Machine learning is the science of getting computers to act without
being explicitly programmed.
 In the past decade, machine learning has given us self-driving cars,
practical speech recognition, effective web search, and a vastly
improved understanding of the human genome.
 Machine learning is so pervasive today that you probably use it
dozens of times a day without knowing it.
 Many researchers also think it is the best way to make progress
towards human-level AI.
 Machine learning, a branch of artificial intelligence, concerns the
construction and study of systems that can learn from data.
Introduction to AI - CoSc3112 7
Introduction to Machine learning
 For example, a machine learning system could be trained on email
messages to learn to distinguish between spam and non-spam messages.
 After learning, it can then be used to classify new email messages into
spam and non-spam folders.
 The core of machine learning deals with representation and
generalization.
 Representation of data instances and functions evaluated on these
instances are part of all machine learning systems.
 Generalization is the property that the system will perform well on
unseen data instances; the conditions under which this can be guaranteed
are a key object of study in the subfield of computational learning theory.

Introduction to AI - CoSc3112 8
Introduction to Machine learning
 There are a wide variety of machine learning tasks and successful
applications.
 Optical character recognition, in which printed characters are recognized
automatically based on previous examples, is a classic example of machine
learning.
 An Intelligent agent which is designed to perform with a sort machine
learning ability is said to be learning agents.
 A machine learning agent is commonly called machine learning
algorithm in field of artificial intelligence.
 Learning agents are common intelligent agents discussed in the earlier
chapters of the course designed in a primary objective of learning
something and understanding instead of problem solving.

Introduction to AI - CoSc3112 9
Introduction to Machine learning
 The various strategies used by machine learning agents or machine
learning algorithms can be organized into a taxonomy based on the
desired outcome of the algorithm or the type of input available during
training the machine as follows.
 Based on Learning Strategies:-
 Supervised learning algorithms
 Unsupervised learning algorithms
 Reinforcement learning algorithms

Introduction to AI - CoSc3112 10
Learning Type
 Supervised learning algorithms:
 It is applicable when a machine has sample input and output data.
 The agent observes input-output pairs and learns a function that
maps from input to output. An output is called a label.
 Basically, the model is trained over a labeled dataset.
 A labeled database is one which contains both inputs as well as the output.
 The agent learns a function that, when given a new image, predicts
the appropriate label.
 Here the trained dataset act a teacher, and its primary role is to train the
model. The prediction is made once the model is built.
 The task is to learn a function y = h(x).

Introduction to AI - CoSc3112 11
Learning Type
 Supervised learning algorithms:
 For example, the inputs could be camera images and an output saying
“bus” or “pedestrian,” etc.

 The task is to learn a function y = h(x).


 Supervised learning problems can be further grouped into:
 Regression and Classification

Introduction to AI - CoSc3112 12
Learning Type
 Supervised learning algorithms:
 Linear Regression and Classification
 Simply if Learning a function whose output is a continuous or ordered
value (like weight) is called regression;
 In linear regression, given features and labels (X,Y), where Y is real-valued,
we try to learn a function f(x) to predict Y given x.

Figure 19.13 (a) Data points of price


versus floor space of houses for sale in
Berkeley, CA, in July 2009, along with
the linear function hypothesis that
minimizes squared-error loss:
y = 0.232x+246.

Introduction to AI - CoSc3112 13
Learning Type
 Supervised learning algorithms:
 Classification
 Simply if learning a function with a small number of possible output
categories is called classification;
 It is used whenever there is some certain (discrete value) output variable,
i.e., either Red or Blue,Yes-No, Male-Female, 0 or 1, etc.
 Logistic regression is used in classification problems(either 0 or 1).

Introduction to AI - CoSc3112 14
Learning Type
 Unsupervised learning algorithms:
 The agent learns patterns in the input without any explicit feedback.
 It is a kind of learning in which the output target is not given to the
model while performing the training. It only has the input variables.
 The model has to lean itself.
 The trained data that is fed to the system can be unlabeled as well as
unstructured in nature.
 The unstructured data is the one where the noise or some irrelevant
information is present.
 The most common unsupervised learning task is clustering:
 detecting potentially useful clusters of input examples.

Introduction to AI - CoSc3112 15
Learning Type
 Unsupervised learning algorithms:
 The agent learns patterns in the input without any explicit feedback.
 It is a kind of learning in which the output target is not given to the
model while performing the training. It only has the input variables.
 The model has to lean itself.
 The trained data that is fed to the system can be unlabeled as well as
unstructured in nature.
 The unstructured data is the one where the noise or some irrelevant
information is present.
 The most common unsupervised learning task is clustering:
 detecting potentially useful clusters of input examples.

Introduction to AI - CoSc3112 16
Learning Type
 Reinforcement learning algorithms:
 The agent learns from a series of reinforcements: rewards and
punishments.
 In such type of learning, agents (computer programs) need to explore the
environment, perform actions, and on the basis of their actions, they get rewards as
feedback.
 For each good action, they get a positive reward, and for each bad action, they get
a negative reward.
 The goal of a Reinforcement learning agent is to maximize the positive rewards.
 Since there is no labeled data, the agent is bound to learn by its experience only.

Introduction to AI - CoSc3112 17
Learning Type
 Reinforcement learning algorithms:
 The agent learns from a series of reinforcements: rewards and
punishments.
 In such type of learning, agents (computer programs) need to explore the
environment, perform actions, and on the basis of their actions, they get rewards as
feedback.
 For each good action, they get a positive reward, and for each bad action, they get
a negative reward.
 The goal of a Reinforcement learning agent is to maximize the positive rewards.
 Since there is no labeled data, the agent is bound to learn by its experience only.

Introduction to AI - CoSc3112 18
Deep Learning Algorithms

Neural networks and back-propagation


Convolution neural networks
Recurrent neural networks and LSTMs

Introduction to AI - CoSc3112 19
Deep Learning Algorithms
 Deep learning is a broad family of techniques for machine learning.
 The word “deep” refers to the fact that the circuits are organized into
many layers, which means that computation paths from inputs to
outputs have many steps.
 Deep learning is achieving the results that were not possible before.
 The computer model learns to perform classification tasks directly from
images, text, and sound with the help of deep learning.
 The models of deep learning can achieve the state-of-art accuracy
and exceed the human-level performance.
 These models of deep learning are trained by using the largest set of
labeled data and neural network architectures that contain many layers.

Introduction to AI - CoSc3112 20
Deep Learning Algorithms

 Deep learning is a broad family of techniques for machine learning.


 The word “deep” refers to the fact that the circuits are organized into
many layers, which means that computation paths from inputs to
outputs have many steps.
 Deep learning is achieving the results that were not possible before.
 The computer model learns to perform classification tasks directly from
images, text, and sound with the help of deep learning.
 The models of deep learning can achieve the state-of-art accuracy
and exceed the human-level performance.
 These models of deep learning are trained by using the largest set of
labeled data and neural network architectures that contain many layers.
Introduction to AI - CoSc3112 21
Deep Learning Algorithms
 There are different types of algorithms that exist in deep learning.
 These algorithms run data through several "layers" of the neural network
algorithm.
 Deep learning requires a large amount of data to learn.
 Deep learning is currently the most widely used approach for
applications such as
‒ visual object recognition,
‒ machine translation,
‒ speech recognition,
‒ speech synthesis, and image synthesis;

Introduction to AI - CoSc3112 22
Deep Learning Algorithms
 Deep learning has its origins in early work that tried to model networks
of neurons in the brain with computational circuits.
 The networks trained by deep learning methods are often called
neural networks.
 Artificial Neural Network or Neural Network was modeled after the
human brain.
 Human has a mind to think and to perform the task in a particular
condition, but how can the machine do that thing?
 For this purpose, the artificial brain was designed, which is called a neural
network.

Introduction to AI - CoSc3112 23
Deep Learning Algorithms
 Similar to the human brain has neurons for passing information;
‒ the same way the neural network has nodes to perform that task.

 A neural network is based on the structure and functions of biological


neural networks.
 A neural network itself changes or learn based on input and output.

Introduction to AI - CoSc3112 24
Deep Learning Algorithms
 The typical ANN looks something like the given figure.

Components of
an Artificial
Neural Network

 Relationship between Biological neural network and artificial neural network


Biological Neural Network Artificial Neural Network

Dendrites Inputs
Cell nucleus Nodes
Synapse Weights
Axon Output
Introduction to AI - CoSc3112 25
Deep Learning Algorithms
 When training a neural network, an algorithm is used to minimize the loss.
 This algorithm is called as Gradient Descent.
 And loss refers to the incorrect outputs given by the hypothesis function.
 Multilayer Neural Network is the artificial neural network that has an input
layer, an output layer and at least one hidden layer in between.
 The number of nodes in the hidden layer and the number of hidden layers can be
decided accordingly.
 Each node in the hidden layer calculates its output value based on the linear
relationship with inputs, and again, Output will be calculated based on the output
values of the nodes in the hidden layers.
 Each node's output value will be multiplied by its respective weight, and then the
final Output will be calculated.

Introduction to AI - CoSc3112 26
Deep Learning Algorithms
 The question arises of how we train this model.
 As the data, we are always given have the values of input data and output
data, but we don't have values of the nodes in the hidden layer.
 To solve this problem, there's a new algorithm called Backpropagation.
 Backpropagation is the algorithm which is used to train the neural
networks with multiple hidden layers.

Introduction to AI - CoSc3112 27
Deep Learning Algorithms
 As we know while training the Multilayer neural network we have input
and output values and we need to calculate the values of each node in all
the hidden layers to train the network properly.
 Steps followed are:
• Start with the random values of weights.
• Repeat
• Firstly the error in the output layer is calculated.
• For every layer, starting from the output layer moving back inward
towards the first hidden layer from the output layer.
• Calculate the error in the back layer based on the values of weights.
• Then, Update the weights.
 Backpropagation algorithm is the key algorithm through which multilayer
neural networks are trained based on the values of weights and create a
function to minimize the loss.
Introduction to AI - CoSc3112 28
Deep Learning Algorithms
 Types of Artificial Neural Network:
‒ Neural Network works similarly as the human nervous system works.
There are several types of neural network.
‒ These networks implementation are based on the set of parameter
and mathematical operation that is required for determining the
output.
‒ Most widely used are:
1. Convolution neural networks
2. Recurrent neural networks and LSTMs

Introduction to AI - CoSc3112 29
Deep Learning Algorithms
 Convolution Neural Networks
‒ In deep learning, a convolutional neural network (CNN, or ConvNet)
is a class of artificial neural network (ANN), most commonly applied
to analyze visual imagery.
‒ Convolutions are a set of layers that go before the neural network
architecture.
‒ Convolutional networks are particularly well suited for image
processing and other tasks where the data have a grid topology.

Introduction to AI - CoSc3112 30
Deep Learning Algorithms
 Convolution Neural Networks
Example

Introduction to AI - CoSc3112 31
Reading Assignment 5
1. Machine learning models
2. Deep learning models

Introduction to AI - CoSc3112 32

You might also like