Professional Documents
Culture Documents
Network
Logistic Regression (Recap)
• In linear regression:
• In logistic regression: (activation function)
• Where (sigmoid function or the logistic function)
• Hence the name logistic regression
• But it is a classifier that is extended from linear regression
• Finally
Logistic Regression (Recap)
• The use of activation function is to
• introduce non-linearity
• transform the linear combination of input and weights into the form that can be interpreted as
probabilities in the range of [0, 1]
• Activation function makes logistic regression suitable for classification.
1
• Task is to select parameters to fit the date
0.5
0
Logistic Regression (Recap)
• Process:
• Scale the data
• Initialize parameter
• Compute the cost function
• Update parameters to reduce cost (gradient descent)
Logistic Regression (Recap)
Parameters or
Weights
• Perceptron: a model that assigns weights to the inputs combine them in a linear
fashion and applies activation function to give output.
NN and the Brain
Neuron model: Logistic unit
Parameters or
Weights
Andrew Ng
Neural Network
Add .
Andrew Ng
Neural Network learning its own features
Andrew Ng
Other network architectures
Input Output
Hidden Layer
Layer Layer
Andrew Ng
Non-linear classification example: XOR/XNOR x1, x2 Features
x2
x2
x1
x1
Andrew Ng
Simple example: AND 0.99 g(z)
0.5
0.01
-30 -4.0 4.0 z
20
20
0 0 g(-30) ≈ 0
= g(-30 + 20 + 20 ) 0 1 g(-10) ≈ 0
1 0 g(-10) ≈ 0
1 1 g(10) ≈ 1
≈ AND
Andrew Ng
Example: OR function
-10
20 0 0
20 0 1
1 0
1 1
Andrew Ng
Negation:
10
-20
0 nor
Andrew Ng
Putting it together:
-30 10 -10
20 -20 20
20 -20 20
0 0
0 1
1 0
1 1
Andrew Ng
Neural Network intuition
Andrew Ng
Multiple output units: One-vs-all.
Want , , , etc.
when pedestrian when car when motorcycle
Andrew Ng
Multiple output units: One-vs-all.
Want , , , etc.
when pedestrian when car when motorcycle
Training set:
one of ,, ,
pedestrian car motorcycle truck
Andrew Ng
Neural
Networks
Cost Function
Neural Network (Classification)
total no. of layers in network
no. of units (not counting bias unit) in
layer
Layer 1 Layer 2 Layer 3 Layer 4
Andrew Ng
Cost function
Logistic regression:
Neural network:
Andrew Ng
Neural Networks
Backpropagation
Algorithm
Gradient computation
Need to compute:
-
-
Gradient computation
Given one training example ( , ):
Forward propagation:
Derivative
Backpropagation
Intuition
Forward Propagation
Forward Propagation
(2 )
Θ 10
(2 )
𝑥1
(𝑖) Θ 11
(𝑖)
𝑥2
Andrew Ng
Forward Propagation
𝛿
(3)
1
𝛿( 4 )
(3)
𝛿2
Andrew Ng
Training a neural network
Pick a network architecture (connectivity pattern between neurons)
Andrew Ng
Activation
Function
Why do NNs Need an Activation Function?
• To add non-linearity to the neural network.
• The main catch here is that the ReLU function does not
activate all the neurons at the same time.