Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

APL 745

ML Basics
Introduction
Dr. Rajdip Nayek
Block V, Room 418D
Department of Applied Mechanics
Indian Institute of Technology Delhi

E-mail: rajdipn@iitd.ac.in
Outline
• Machine learning vs classical programming

• Supervised vs Unsupervised vs Reinforcement learning

• Brief introduction to neurons and neural networks

2
Classical programming vs Machine learning
• Classical programming
• Program/code the rules for every task

Data
Classical Answers
Rules programming

• For many problems, it is difficult to program the correct behaviour by hand


• recognizing people, objects
• understanding human speech

• Machine learning approach: program an algorithm to automatically learn


rules from data, or from experience

Data
Machine Rules
Answers Learning
3
Types of machine learning
Broadly speaking, there are three types of machine learning algorithms

Supervised Reinforcement Unsupervised


Inputs and Rewards are Only inputs are
corresponding outputs provided based on provided
are provided actions

Teacher provides answer Teacher provides rewards No teacher, find patterns!

• Classification • Gaming • Clustering


• Regression • Control • Visualization
4
Supervised learning examples
Supervised learning: have labelled examples of what is “correct”
e.g. Handwritten digit classification with the MNIST dataset

• Task: Given an image of a handwritten digit, predict the digit class


• Input: a handwritten image of a digit
• Output (or target): the digit class

• Data: 70,000 images of handwritten digits labelled by humans


• Training set: first 60,000 images used to train the network
• Test set: last 10,000 images, not used during training, used to assess
performance

5
Supervised learning examples

What type of images look like a “2”?

Misclassification
6
Supervised learning examples
Object Recognition: Detect the class of the object

• ImageNet

• 1.2 million labelled


images

• 1000 classes

• Lots of variability in
lighting, viewpoint,
etc.

• Deep neural
networks reduced
error rates from
26% to under 4%

7
Supervised learning examples
Machine Translation: Translate a sentence from one language to another
Wu et al.
2016

Google
Neural
Machine
Translation
(GNMT)

8
Unsupervised learning examples
Unsupervised learning: no labelled examples, you only have input data. You
are looking for interesting patterns in the data
• To find clusters in data

• To find a compressed representation

• To find a generative model that could be used to generate more data

E.g. Clustering – Group the input data into separate classes

Elastic mod. Poisson’s ratio

Poisson’s ratio
210 GPa 0.279
70 GPa 0.325
⋮ ⋮
190 GPa 0.267 Elastic modulus
9
Unsupervised learning examples
Unsupervised learning: no labelled examples, you only have input data. You
are looking for interesting patterns in the data
• To find clusters in data

• To find a compressed representation

• To find a generative model that could be used to generate more data

E.g. Compressed representation – Find a reduced dimension of the input

10
Unsupervised learning examples
Unsupervised learning: no labelled examples, you only have input data. You
are looking for interesting patterns in the data

• In generative modeling, we want to learn a distribution over some


dataset, such as natural images. We can then sample from the generative
model and see how the if it looks like the data.

Generated faces
(not true faces)

11
Reinforcement learning
Computer playing a game
Computer (agent that performs action)
Agent

State Reward Action

Environment
Game (environment)

Goal: Learn to choose actions that maximize rewards

• An agent (e.g. player) interacts with an environment (e.g. enemy-killing game)


• In each time step
• the agent receives observations of the state (e.g. how many enemies remaining)
• the agent picks an action (e.g. moving to safe location, or killing an enemy)
• The agent will periodically receive some rewards (e.g. health, ammunition, scores)
12
Idea of RL is based on animal psychology

• Reinforcements are used to train animals

• Negative reinforcements
• Hunger
• Pain

• Positive reinforcements
• Food
• Pleasure

• This psychology is applied here to computers


• Rewards: numbers or numerical signals indicating how good the
agent performed
• Example of rewards: Win/loss in games, points earned, etc.

13
Neurons
and
Neural Networks

14
Computer emulation of human brain
• Many decades back, researchers suggested the idea that the computer
can be as powerful as the human brain

• Brain can learn, process environments and take decisions

• Question: Is it possible to structure the computer to learn like a human


brain?

• Brains consists of important class of nerve cells called neurons

• Want computational units that can mimic the architecture of neurons


Neuron
• The neuron is the basic unit of processing in the brain

• It has a broad, branching tree of dendrites, which receive chemical signals


from other neurons convert these into electrical signals

• If the combined signal from the different dendrites is strong enough, the
neuron generates an action potential in the form of an electrical signal

• This electrical signal is propagated


down the neuron’s axon, which
eventually causes the neuron to
release chemical signals

16
Neural networks
• Idea: Mimic the brain to do computation
• Nodes (also called units) correspond to nucleui
• Links (arrows) correspond to dendrites

• A single processing unit: The output node (𝑦) has incoming connections
from input nodes (𝑥), each associated with a weight (𝑤)

𝑦
𝑦
Output node
Output node
𝑏 Weights
Bias 𝑏 𝑤𝐾
Bias 𝑤1
Weights 𝑤1 𝑤𝐾 1 𝑥1 ⋯ 𝑥𝐾
𝑥1 𝑥𝐾 Input nodes

Input nodes
17
Neural networks
• Idea: Mimic the brain to do computation
• Nodes (also called units) correspond to nucleui
• Links (arrows) correspond to dendrites

• A single processing unit: The output node (𝑦) has incoming connections
from input nodes (𝑥), each associated with a weight (𝑤)

Weights Input
𝑦 Bias
Output node 𝑦 = 𝜎 𝒘𝑇 𝒙 + 𝑏
Weights Output
Bias 𝑏 𝑤𝐾
𝑤1 Nonlinear
1 𝑥1 Activation
⋯ 𝑥𝐾 function
Input nodes

18
Neural networks
• Activation functions are usually nonlinear

• Hard threshold Weights Input


1 𝑧>0 𝑦 = 𝜎 𝒘𝑇 𝒙 + 𝑏
𝜎 𝑧 =ቊ
0 𝑧≤0
Output Bias
• Sigmoid activation function
Activation
function
1
𝜎 𝑧 =
1 + 𝑒 −𝑧

• Rectified linear units (ReLU)

𝑧 𝑧>0
𝜎 𝑧 =ቊ
0 𝑧≤0

• Neural networks are collections of thousands (or millions) of processing


units that together perform useful computations
19
“Deep learning”
• Deep learning: Many layers (stages) of processing units
• E.g. an ENCODER trained on a large set of different images; the internal
nodes denote learned features

Images
from
ImageNet

You can visualize what a learned feature corresponds to


by finding an image that excites it
20

You might also like