SlideShare a Scribd company logo
1 of 78
Download to read offline
Copyright Notice
These slides are distributed under the Creative Commons License.
DeepLearning.AI makes these slides available for educational purposes. You may not use or distribute
these slides for commercial purposes. You may make copies of these slides and use or distribute them for
educational purposes as long as you cite DeepLearning.AI as the source of the slides.
For the rest of the details of the license, see https://creativecommons.org/licenses/by-sa/2.0/legalcode
Advanced Learning Algorithms
Welcome!
Andrew Ng
Advanced learning algorithms
Neural Networks
inference (prediction)
training
Practical advice for building machine learning systems
Decision Trees
Neural Networks Intuition
Neurons and the brain
Andrew Ng
Neural networks
Origins: Algorithms that try to mimic the brain.
Used in the 1980’s and early 1990’s.
Fell out of favor in the late 1990’s.
Resurgence from around 2005.
speech images text (NLP)
Neurons in the brain
[Credit: US National Institutes of Health, National Institute on Aging]
Andrew Ng
image source: https://biologydictionary.net/sensory-neuron/
inputs outputs
Simplified mathematical
model of a neuron
inputs outputs
Biological neuron
Andrew Ng
Why Now?
performance
amount of data
traditional AI
medium neural network
small neural network
large neural network
Neural Network Intuition
Demand Prediction
Andrew Ng
Demand Prediction
top seller?
yes/no
price
𝑥
1
1 + 𝑒− 𝑤𝑥+𝑏
input
output
𝑥 𝑎
𝑓 𝑥 =
𝑎 =
= 𝑝𝑟𝑖𝑐𝑒
Andrew Ng
Demand Prediction
probability of
being a top seller
layer
layer
price
shipping cost
marketing
material
Andrew Ng
Demand Prediction
probability of
being a top seller
layer
layer
price
shipping cost
marketing
material
a a
Andrew Ng
Demand Prediction
probability of
being a top seller
layer
layer
price
shipping cost
marketing
material
a a
Andrew Ng
Multiple hidden layers
x
input
hidden
layer
hidden
layer
output
layer
hidden
layer
hidden
layer
hidden
layer
neural network architecture
x
a a
Neural Networks Intuition
Example:
Recognizing Images
Andrew Ng
x =
Face recognition
Andrew Ng
Face recognition
x
input
output layer
probability of being
person ‘XYZ’
source: Convolutional Deep Belief Networks for Scalable Unsupervised Learning of Hierarchical Representations
by Honglak Lee, Roger Grosse, Ranganath Andrew Y. Ng
⋮
⋮
⋮
Andrew Ng
probability of
car detected
source: Convolutional Deep Belief Networks for Scalable Unsupervised Learning of Hierarchical Representations
by Honglak Lee, Roger Grosse, Ranganath Andrew Y. Ng
Car classification
output layer
⋮
⋮
⋮
Neural network model
Neural network layer
Andrew Ng
x
Neural network layer
Andrew Ng
x
x
𝑤1 ,𝑏1
w2 ,𝑏2
w3 ,𝑏3 𝑎3 = 𝑔(w3 ∙ x + 𝑏3 )
𝑔(𝑧) =
1
1 + 𝑒− 𝑧
Neural network layer
𝑎2
[1]
= 𝑔(w2
[1]
∙ x + 𝑏2
[1]
)
𝑎1
[1]
= 𝑔(w1
[1]
∙ x + 𝑏1
[1]
)
layer 1
layer 2
layer 0
a[1]
a[1]
notation for layer
numbering
vector of
activation
values from
layer 1
Andrew Ng
x
𝑤1 ,𝑏1
a
Neural network layer
a[1]
𝑎1
[1]
= 𝑔(w1
[1]
∙ a[1]
+ 𝑏1
[1]
)
𝑔(𝑧) =
1
1 + 𝑒− 𝑧
layer 2
layer 1
a[1]
𝑎[2]
a scalar
value
Andrew Ng
x
Neural network layer
a[1]
𝑎[2]
layer 1
layer 2
𝑖𝑠 𝑎
2
≥ 0.5?
ො
𝑦 = 1 ො
𝑦 = 0
predict category 1 or 0 (yes/no)
More complex neural networks
Neural Network Model
Andrew Ng
More complex neural network
x
input
a[1] a[2]
a[3]
a[4]
layer 1 layer 2 layer 3 layer 4
hidden layers
layer 0
output
layer
Andrew Ng
More complex neural network
x
input
a[1] a[2]
a[3]
a[4]
layer 1 layer 2 layer 3 layer 4
𝑤1
[3]
,𝑏1
[3]
w2
[3]
,𝑏2
[3]
w3
[3]
,𝑏3
[3]
𝑎3
[3]
= 𝑔(w3
[3]
∙ a[2]
+ 𝑏3
[3]
)
𝑎2
[3]
= 𝑔(w2
[3]
∙ a[2]
+ 𝑏2
[3]
)
𝑎1
[3]
= 𝑔(w1
[3]
∙ a[2]
+ 𝑏1
[3]
)
a[2] a[3]
Andrew Ng
Notation
x
input
a[1] a[2]
a[3]
a[4]
layer 1 layer 2 layer 3 layer 4
𝑤1
[3]
,𝑏1
[3]
w2
[3]
,𝑏2
[3]
w3
[3]
,𝑏3
[3]
𝑎3
[3]
= 𝑔(w3
[3]
∙ a[2]
+ 𝑏3
[3]
)
𝑎2
[3]
= 𝑔(w2
[3]
∙ a[2]
+ 𝑏2
[3]
)
𝑎1
[3]
= 𝑔(w1
[3]
∙ a[2]
+ 𝑏1
[3]
)
a[2] a[3]
Question:
Can you fill in the superscripts and
subscripts for the second neuron?
Andrew Ng
Notation
x
input
a[1] a[2]
a[3]
a[4]
layer 1 layer 2
layer 3 layer 4
𝑤1
[3]
,𝑏1
[3]
w2
[3]
,𝑏2
[3]
w3
[3]
,𝑏3
[3]
𝑎3
[3]
= 𝑔(w1
[3]
∙ a[2]
+ 𝑏1
[3]
)
𝑎1
[3]
a[2]
Activation value of
layer 𝑙, unit(neuron) 𝑗
Parameters w & b of layer 𝑙, unit 𝑗
output of layer 𝑙 − 1
(previous layer)
sigmoid
x
𝑎2
[3]
= 𝑔(w2
[3]
∙ a[2]
+ 𝑏2
[3]
)
= 𝑔(w3
[3]
∙ a[2]
+ 𝑏3
[3]
)
𝑎2
[3]
= 𝑔(w2
[3]
∙ a[2]
+ 𝑏2
[3]
) a[3]
= 𝑔(w𝑗
[𝑙]
∙ a[𝑙−1] + 𝑏𝑗
[𝑙]
)
𝑎𝑗
[𝑙]
Neural Network Model
Inference: making predictions
(forward propagation)
Andrew Ng
Handwritten digit recognition
x
output
layer
probability
of being a
handwritten ‘1’
25 units 15 units
a[1]
⋮
⋮
a[1] a[2]
a[3]
1 unit
layer 1 layer 2 layer 3
Digit images
label 0 1
Andrew Ng
Handwritten digit recognition
x
output
layer
25 units 15 units a[2]
⋮
⋮
a[1] a[2]
a[3]
1 unit
layer 1 layer 2 layer 3
Digit images
label 0 1
probability
of being a
handwritten ‘1’
Andrew Ng
Handwritten digit recognition
output
layer
probability
of being a
handwritten ‘1’
⋮ ⋮
25 units 15 units
a[2] a[3]
a[3]
= 𝑔 w1
3
∙ a 2
+ 𝑏1
3
𝑖𝑠 𝑎1
3
≥ 0.5?
ො
𝑦 = 1 ො
𝑦 = 0
1 unit
forward propagation
a[1]
x
layer 1 layer 2 layer 3
𝑓(𝑥)
=
image is digit 1 image isn’t digit 1
TensorFlow implementation
Inference in Code
Andrew Ng
Coffee roasting
a[1]
a[2]
𝑖𝑠 𝑎1
2
≥ 0.5?
ො
𝑦 = 1 ො
𝑦 = 0
x
Temperature
(Celsius)
Duration
(minutes)
Andrew Ng
a[1]
a[2]
x
x = np.array([[200.0, 17.0]])
layer_1 = Dense(units=3, activation=‘sigmoid’)
a1 = layer_1(x)
Andrew Ng
Build the model using TensorFlow
a[1]
a[2]
layer_2 = Dense(units=1, activation=‘sigmoid’)
a2 = layer_2(a1)
x = np.array([[200.0, 17.0]])
layer_1 = Dense(units=3, activation=‘sigmoid’)
a1 = layer_1(x)
x
Andrew Ng
Build the model using TensorFlow
𝑖𝑠 𝑎1
2
≥ 0.5?
if a2 >= 0.5:
yhat = 1
else:
yhat = 0
ො
𝑦 = 1 ො
𝑦 = 0
layer_2 = Dense(units=1, activation=‘sigmoid’)
a2 = layer_2(a1)
x = np.array([[200.0, 17.0]])
layer_1 = Dense(units=3, activation=‘sigmoid’)
a1 = layer_1(x)
a[1]
a[2]
x
Andrew Ng
Model for digit classification
x ⋮
⋮
25 units
15 units
a[2]
a[3]
1 unit
x = np.array([[0.0,...245,...240...0]])
layer_1 = Dense(units=25, activation=‘sigmoid’)
a1 = layer_1(x)
a[1]
Andrew Ng
Model for digit classification
x ⋮
⋮
25 units
15 units
a[1]
a[2]
a[3]
1 unit
x = np.array([[0.0,...245,...240...0]])
layer_1 = Dense(units=25, activation=‘sigmoid’)
a1 = layer_1(x)
layer_2 = Dense(units=15, activation=‘sigmoid’)
a2 = layer_2(a1)
Andrew Ng
Model for digit classification
x ⋮
⋮
25 units
15 units
a[2]
a[3]
1 unit
x = np.array([[0.0,...245,...240...0]])
layer_1 = Dense(units=25, activation=‘sigmoid’)
a1 = layer_1(x)
layer_2 = Dense(units=15, activation=‘sigmoid’)
a2 = layer_2(a1)
layer_3 = Dense(units=1, activation=‘sigmoid’)
a3 = layer_3(a2)
a[1]
Andrew Ng
Model for digit classification
x ⋮
⋮
25 units
15 units
a[2]
a[3]
1 unit
x = np.array([[0.0,...245,...240...0]])
layer_1 = Dense(units=25, activation=‘sigmoid’)
a1 = layer_1(x)
layer_2 = Dense(units=15, activation=‘sigmoid’)
a2 = layer_2(a1)
if a3 >= 0.5:
yhat = 1
else:
yhat = 0
layer_3 = Dense(units=1, activation=‘sigmoid’)
a3 = layer_3(a2)
𝑖𝑠 𝑎1
3
≥ 0.5?
ො
𝑦 = 1 ො
𝑦 = 0
a[1]
TensorFlow implementation
Data in TensorFlow
Andrew Ng
Feature vectors
temperature
(Celsius)
duration
(minutes)
Good coffee?
(1/0)
200.0 17.0 1
425.0 18.5 0
… … …
x = np.array([[200.0, 17.0]])
[[200.0, 17.0]]
Andrew Ng
Note about numpy arrays
1 2 3
4 5 6
x = np.array([[1, 2, 3],
[4, 5, 6]])
[[1, 2, 3],
[4, 5, 6]]
x = np.array([[0.1, 0.2],
[-3.0, -4.0,],
[-0.5, -0.6,],
[7.0, 8.0,]])
[[0.1, 0.2],
[-3.0, -4.0,],
[-0.5, -0.6,],
[7.0, 8.0,]]
2 x 3
4 x 2
1 x 2
2 x 1
Andrew Ng
Note about numpy arrays
x = np.array([[200, 17]])
x = np.array([[200],
[17]])
x = np.array([200,17])
200
17
200 17 1 x 2
2 x 1
Andrew Ng
Feature vectors
temperature
(Celsius)
duration
(minutes)
Good coffee?
(1/0)
200.0 17.0 1
425.0 18.5 0
… … …
x = np.array([[200.0, 17.0]])
[[200.0, 17.0]]
200.0 17.0
1 x 2
Andrew Ng
Activation vector
a[1]
a[2]
x
x = np.array([[200.0, 17.0]])
layer_1 = Dense(units=3, activation=‘sigmoid’)
a1 = layer_1(x)
tf.Tensor([[0.2 0.7 0.3]], shape=(1, 3), dtype=float32)
a1.numpy()
array([[1.4661001, 1.125196 , 3.2159438]], dtype=float32)
1 x 3 matrix
Andrew Ng
Activation vector
a[1]
a[2]
x
layer_2 = Dense(units=1, activation=‘sigmoid’)
a2 = layer_2(a1)
tf.Tensor([[0.8]], shape=(1, 1), dtype=float32)
a2.numpy()
array([[0.8]], dtype=float32)
1 x 1
TensorFlow implementation
Building a neural network
Andrew Ng
What you saw earlier
layer_2 = Dense(units=1, activation="sigmoid")
a2 = layer_2(a1)
x = np.array([[200.0, 17.0]])
layer_1 = Dense(units=3, activation="sigmoid")
a1 = layer_1(x)
a[1]
a[2]
x
Andrew Ng
Building a neural network architecture
layer_2 = Dense(units=1, activation="sigmoid")
layer_1 = Dense(units=3, activation="sigmoid")
a[1]
a[2]
x
model = Sequential([layer_1, layer_2])
model.fit(x,y)
model.compile(...)
x = np.array([[200.0, 17.0],
[120.0, 5.0],
[425.0, 20.0],
[212.0, 18.0])
y = np.array([1,0,0,1])
model.predict(x_new)
y
200 17 1
120 5 0
425 20 0
212 18 1
4 x 2
Andrew Ng
layer_1 = Dense(units=25, activation="sigmoid")
Digit classification model
x ⋮
⋮
25 units
15 units
a[2]
a[3]
1 unit
a[1]
layer_2 = Dense(units=15, activation="sigmoid")
model = Sequential([layer_1, layer_2, layer_3]
model.fit(x,y)
model.compile(...)
x = np.array([[0..., 245, ..., 17],
[0..., 200, ..., 184])
y = np.array([1,0])
layer_3 = Dense(units=1, activation="sigmoid")
model.predict(x_new)
Andrew Ng
Digit classification model
x ⋮
⋮
25 units
15 units
a[2]
a[3]
1 unit
a[1]
model = Sequential([
Dense(units=25, activation="sigmoid"),
Dense(units=15, activation="sigmoid"),
Dense(units=1, activation="sigmoid")])
model.compile(...)
x = np.array([[0..., 245, ..., 17],
[0..., 200, ..., 184])
y = np.array([1,0])
model.fit(x,y)
model.predict(x_new)
Neural network implementation
in Python
Forward prop in a single layer
Andrew Ng
forward prop (coffee roasting model)
𝑎1
[1]
= 𝑔(w1
[1]
∙ x + 𝑏1
[1]
)
x = np.array([200, 17])
w1_1 = np.array([1, 2])
b1_1 = np.array([-1])
z1_1 = np.dot(w1_1,x)+ b
a1_1 = sigmoid(z1_1)
𝑎2
[1]
= 𝑔(w2
[1]
∙ x + 𝑏2
[1]
)
w1_2 = np.array([-3, 4])
b1_2 = np.array([1])
z1_2 = np.dot(w1_2,x)+b
a1_2
𝑎3
[1]
= 𝑔(w3
[1]
∙ x + 𝑏3
[1]
)
w1_3 = np.array([5, -6])
b1_3 = np.array([2])
z1_3 = np.dot(w1_3,x)+b
a1_3 = sigmoid(z1_3)
𝑎1
[2]
= 𝑔(w1
[2]
∙ a[1]
+ 𝑏1
[2]
)
b2_1 = np.array([3])
z2_1 = np.dot(w2_1,a1)+b2_1
a2_1 = sigmoid(z1_1)
w2_1 = np.array([-7, 8])
a[1] a[2]
x
𝑤1
[1]
,𝑏1
[1]
w2
[1]
,𝑏2
[1]
w3
[1]
,𝑏3
[1]
𝑤1
[2]
,𝑏1
[2]
a1 = np.array([a1_1, a1_2, a1_3])
= sigmoid(z1_2)
w2_1
Neural network implemenation
in Python
General implementation of
forward propagation
Andrew Ng
Forward prop in NumPy
def dense(a_in,W,b, g):
units = W.shape[1]
a_out = np.zeros(units)
for j in range(units):
w = W[:,j]
z = np.dot(w,a_in) + b[j]
a_out[j] = g(z)
return a_out
def sequential(x):
a1 = dense(x,W1,b1,g)
a2 = dense(a1,W2,b2,g)
a3 = dense(a2,W3,b3,g)
a4 = dense(a3,W4,b4,g)
f_x = a4
return f_x
𝑤1
[1]
=
1
2
w2
[1]
=
−3
4
w3
[1]
=
5
−6
𝑏1
[𝑙]
= −1 𝑏2
[𝑙]
= 1 𝑏3
[𝑙]
= 2
𝑤1
[1]
,𝑏1
[1]
w2
[1]
,𝑏2
[1]
w3
[1]
,𝑏3
[1]
a[𝑙]
x
b = np.array([-1, 1, 2])
a_in = np.array([-2, 4])
W = np.array([
[1, -3, 5]
[2, 4, -6]])
a[0]
= x
Speculations on artificial general
intelligence (AGI)
Is there a path to AGI?
Andrew Ng
AI
E.g., smart speaker,
self-driving car, web search,
AI in farming and factories
Do anything a human can do
ANI
(artificial narrow intelligence)
AGI
(artificial general intelligence)
Andrew Ng
image source: https://biologydictionary.net/sensory-neuron/
inputs outputs
Simplified mathematical
model of a neuron
inputs outputs
Biological neuron
Andrew Ng
Neural network and the brain
Can we mimic the human brain?
x 𝑓(x)
vs
We have (almost) no idea how the brain works
Andrew Ng
The ”one learning algorithm” hypothesis
Auditory cortex learns to see
Auditory cortex
[Roe et al., 1992]
Andrew Ng
The ”one learning algorithm” hypothesis
Somatosensory cortex learns to see
Somatosensory cortex
[Metin & Frost, 1989]
Andrew Ng
Sensor representations in the brain
Seeing with your tongue Human echolocation (sonar)
Haptic belt: Direction sense Implanting a 3rd eye
[BrainPort; Welsh & Blasch, 1997; Nagel et al., 2005; Constantine-Paton & Law, 2009]
Vectorization
(optional)
How neural networks are
implemented efficiently
Andrew Ng
For loops vs. vectorization
def dense(a_in,W,b):
a_out = np.zeros(units)
for j in range(units):
w = W[:,j]
z = np.dot(w,x) + b[j]
a[j] = g(z)
return a
def dense(A_in,W,B):
Z = np.matmul(A_in,W) + B
A_out = g(Z)
return A_out
X = np.array([[200, 17]])
W = np.array([[1, -3, 5],
[-2, 4, -6])
B = np.array([[-1, 1, 2]])
[[1,0,1]]
x = np.array([200, 17])
W = np.array([[1, -3, 5],
[-2, 4, -6]])
b = np.array([-1, 1, 2])
[1,0,1]
Vectorization
(optional)
Matrix multiplication
Andrew Ng
Dot products
1
2
∙
3
4
𝑧 = a ∙ w
↑
a
↓
∙
↑
w
↓
↑
w
↓
in general
example vector vector multiplication
a𝑻
= 1 2
← a𝑻 →
transpose
a =
1
2
𝑧 = a𝑻w
Andrew Ng
Vector matrix multiplication
→
w1
→
w2
[ ← →
a
𝑻
→ ]
𝐙 = →
a
𝑻
𝐖
𝐙 = [
→
a
𝑻→
w1 𝑎𝑻→
w2]
𝐙 = [11 17]
(1 ∗ 3) + (2 ∗ 4) (1 ∗ 5) + (2 ∗ 6)
→
a
𝑻
= [1 2]
→
a =
[
1
2]
𝐖 =
[
3 5
4 6]
Andrew Ng
← →
a
𝑇
1 →
← →
a
𝑇
2 →
matrix matrix multiplication
=
[
11 17
− 11 − 17]
𝐖 =
[
3 5
4 6] →
w1
→
w2
𝐀𝑻
=
[
1 2
− 1 − 2]
𝐀 =
[
1 − 1
2 − 2]
=
→
a
𝑇
1
→
w1
→
a
𝑇
1
→
w2
→
a
𝑇
2
→
w1
→
a
𝑇
2
→
w2
𝐙 = 𝐀𝑻
𝐖 =
Vectorization
(optional)
Matrix multiplication rules
Andrew Ng
Matrix multiplication rules
𝐀 =
1 −1 0.1
2 −2 0.2 𝐖 =
3 5 7 9
4 6 8 0 𝒁 = 𝐀𝑻
𝐖 =
𝐀𝑻 =
1 2
−1 −2
0.1 0.2
Andrew Ng
Matrix multiplication rules
𝐀 =
1 −1 0.1
2 −2 0.2 𝐖 =
3 5 7 9
4 6 8 0
𝐀𝑻 =
1 2
−1 −2
0.1 0.2
𝒁 = 𝐀𝑻
𝐖 =
Andrew Ng
𝒁 = 𝐀𝑻
𝐖 =
11 17 23 9
−11 −17 −23 −9
1.1 1.7 2.3 0.9
Matrix multiplication rules
𝐀 =
1 −1 0.1
2 −2 0.2 𝐖 =
3 5 7 9
4 6 8 0
𝐀𝑻 =
1 2
−1 −2
0.1 0.2
Andrew Ng
𝒁 = 𝐀𝑻
𝐖 =
11 17 23 9
−11 −17 −23 −9
1.1 1.7 2.3 0.9
Matrix multiplication rules
𝐀 =
1 −1 0.1
2 −2 0.2 𝐖 =
3 5 7 9
4 6 8 0
𝐀𝑻 =
1 2
−1 −2
0.1 0.2
Vectorization
(optional)
Matrix multiplication code
Andrew Ng
Matrix multiplication in NumPy
Z = np.matmul(AT,W)
A=np.array([1,-1,0.1],
[2,-2,0.2]])
AT=np.array([1,2],
[-1,-2],
[0.1,0.2])
AT=A.T
W=np.array([3,5,7,9],
[4,6,8,0])
Z = AT @ W
[[11,17,23,9],
[-11,-17,-23,-9],
[1.1,1.7,2.3,0.9]
]
𝒁 = 𝐀𝑻
𝐖 =
11 17 23 9
−11 −17 −23 −9
1.1 1.7 2.3 0.9
𝐀 =
1 −1 0.1
2 −2 0.2 𝐖 =
3 5 7 9
4 6 8 0
𝐀𝑻 =
1 2
−1 −2
0.1 0.2
Andrew Ng
Dense layer vectorized
def dense(AT,W,b,g):
z = np.matmul(AT,W) + b
a_out = g(z)
return a_out
AT = np.array([[200, 17]])
W = np.array([[1, -3, 5],
[-2, 4, -6])
b = np.array([[-1, 1, 2]])
[[1,0,1]]
𝐀𝑻 = 200 17
𝐖 =
1 −3 5
−2 4 −6
Ԧ
𝐛 = −1 1 2
𝐙 = 𝐀𝑻
𝐖 + 𝐁
𝐀 = g(𝐙)
1 0 1
165 −531 900
𝐀[1] 𝐀[2]
𝐀𝑻
𝑤1
[1]
,𝑏1
[1]
w2
[1]
,𝑏2
[1]
w3
[1]
,𝑏3
[1]
𝑧1
[1]
𝑧3
[1]
𝑧2
[1]

More Related Content

Similar to C2_W1.pdf

Effective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyEffective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyKimikazu Kato
 
Machine Learning: Make Your Ruby Code Smarter
Machine Learning: Make Your Ruby Code SmarterMachine Learning: Make Your Ruby Code Smarter
Machine Learning: Make Your Ruby Code SmarterAstrails
 
An introduction to Deep Learning with Apache MXNet (November 2017)
An introduction to Deep Learning with Apache MXNet (November 2017)An introduction to Deep Learning with Apache MXNet (November 2017)
An introduction to Deep Learning with Apache MXNet (November 2017)Julien SIMON
 
RNN, LSTM and Seq-2-Seq Models
RNN, LSTM and Seq-2-Seq ModelsRNN, LSTM and Seq-2-Seq Models
RNN, LSTM and Seq-2-Seq ModelsEmory NLP
 
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...Simplilearn
 
Deep Residual Hashing Neural Network for Image Retrieval
Deep Residual Hashing Neural Network for Image RetrievalDeep Residual Hashing Neural Network for Image Retrieval
Deep Residual Hashing Neural Network for Image RetrievalEdwin Efraín Jiménez Lepe
 
Digit recognizer by convolutional neural network
Digit recognizer by convolutional neural networkDigit recognizer by convolutional neural network
Digit recognizer by convolutional neural networkDing Li
 
Introduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchIntroduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchAhmed BESBES
 
Neural network in matlab
Neural network in matlab Neural network in matlab
Neural network in matlab Fahim Khan
 
DeepXplore: Automated Whitebox Testing of Deep Learning
DeepXplore: Automated Whitebox Testing of Deep LearningDeepXplore: Automated Whitebox Testing of Deep Learning
DeepXplore: Automated Whitebox Testing of Deep LearningMasahiro Sakai
 
Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)Cdiscount
 
Yoyak ScalaDays 2015
Yoyak ScalaDays 2015Yoyak ScalaDays 2015
Yoyak ScalaDays 2015ihji
 
Introduction to Deep Learning and Tensorflow
Introduction to Deep Learning and TensorflowIntroduction to Deep Learning and Tensorflow
Introduction to Deep Learning and TensorflowOswald Campesato
 
Tutorial on convolutional neural networks
Tutorial on convolutional neural networksTutorial on convolutional neural networks
Tutorial on convolutional neural networksHojin Yang
 
Introduction to Neural Netwoks
Introduction to Neural Netwoks Introduction to Neural Netwoks
Introduction to Neural Netwoks Abdallah Bashir
 
Introduction to Neural Networks
Introduction to Neural NetworksIntroduction to Neural Networks
Introduction to Neural NetworksDatabricks
 
nlp dl 1.pdf
nlp dl 1.pdfnlp dl 1.pdf
nlp dl 1.pdfnyomans1
 
IndabaX Ghana Poster.pdf
IndabaX Ghana Poster.pdfIndabaX Ghana Poster.pdf
IndabaX Ghana Poster.pdfkwadwoAmedi
 

Similar to C2_W1.pdf (20)

Effective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyEffective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPy
 
Machine Learning: Make Your Ruby Code Smarter
Machine Learning: Make Your Ruby Code SmarterMachine Learning: Make Your Ruby Code Smarter
Machine Learning: Make Your Ruby Code Smarter
 
An introduction to Deep Learning with Apache MXNet (November 2017)
An introduction to Deep Learning with Apache MXNet (November 2017)An introduction to Deep Learning with Apache MXNet (November 2017)
An introduction to Deep Learning with Apache MXNet (November 2017)
 
C4_W1 (1).pdf
C4_W1 (1).pdfC4_W1 (1).pdf
C4_W1 (1).pdf
 
RNN, LSTM and Seq-2-Seq Models
RNN, LSTM and Seq-2-Seq ModelsRNN, LSTM and Seq-2-Seq Models
RNN, LSTM and Seq-2-Seq Models
 
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
 
Deep Residual Hashing Neural Network for Image Retrieval
Deep Residual Hashing Neural Network for Image RetrievalDeep Residual Hashing Neural Network for Image Retrieval
Deep Residual Hashing Neural Network for Image Retrieval
 
Digit recognizer by convolutional neural network
Digit recognizer by convolutional neural networkDigit recognizer by convolutional neural network
Digit recognizer by convolutional neural network
 
Introduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from ScratchIntroduction to Neural Networks and Deep Learning from Scratch
Introduction to Neural Networks and Deep Learning from Scratch
 
Neural network in matlab
Neural network in matlab Neural network in matlab
Neural network in matlab
 
C3_W2.pdf
C3_W2.pdfC3_W2.pdf
C3_W2.pdf
 
DeepXplore: Automated Whitebox Testing of Deep Learning
DeepXplore: Automated Whitebox Testing of Deep LearningDeepXplore: Automated Whitebox Testing of Deep Learning
DeepXplore: Automated Whitebox Testing of Deep Learning
 
Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)Parallel R in snow (english after 2nd slide)
Parallel R in snow (english after 2nd slide)
 
Yoyak ScalaDays 2015
Yoyak ScalaDays 2015Yoyak ScalaDays 2015
Yoyak ScalaDays 2015
 
Introduction to Deep Learning and Tensorflow
Introduction to Deep Learning and TensorflowIntroduction to Deep Learning and Tensorflow
Introduction to Deep Learning and Tensorflow
 
Tutorial on convolutional neural networks
Tutorial on convolutional neural networksTutorial on convolutional neural networks
Tutorial on convolutional neural networks
 
Introduction to Neural Netwoks
Introduction to Neural Netwoks Introduction to Neural Netwoks
Introduction to Neural Netwoks
 
Introduction to Neural Networks
Introduction to Neural NetworksIntroduction to Neural Networks
Introduction to Neural Networks
 
nlp dl 1.pdf
nlp dl 1.pdfnlp dl 1.pdf
nlp dl 1.pdf
 
IndabaX Ghana Poster.pdf
IndabaX Ghana Poster.pdfIndabaX Ghana Poster.pdf
IndabaX Ghana Poster.pdf
 

Recently uploaded

Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...only4webmaster01
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsJoseMangaJr1
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...amitlee9823
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 

Recently uploaded (20)

Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 9155563397 👗 Top Class Call Girl Service B...
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 

C2_W1.pdf

  • 1. Copyright Notice These slides are distributed under the Creative Commons License. DeepLearning.AI makes these slides available for educational purposes. You may not use or distribute these slides for commercial purposes. You may make copies of these slides and use or distribute them for educational purposes as long as you cite DeepLearning.AI as the source of the slides. For the rest of the details of the license, see https://creativecommons.org/licenses/by-sa/2.0/legalcode
  • 3. Andrew Ng Advanced learning algorithms Neural Networks inference (prediction) training Practical advice for building machine learning systems Decision Trees
  • 5. Andrew Ng Neural networks Origins: Algorithms that try to mimic the brain. Used in the 1980’s and early 1990’s. Fell out of favor in the late 1990’s. Resurgence from around 2005. speech images text (NLP)
  • 6. Neurons in the brain [Credit: US National Institutes of Health, National Institute on Aging]
  • 7. Andrew Ng image source: https://biologydictionary.net/sensory-neuron/ inputs outputs Simplified mathematical model of a neuron inputs outputs Biological neuron
  • 8. Andrew Ng Why Now? performance amount of data traditional AI medium neural network small neural network large neural network
  • 10. Andrew Ng Demand Prediction top seller? yes/no price 𝑥 1 1 + 𝑒− 𝑤𝑥+𝑏 input output 𝑥 𝑎 𝑓 𝑥 = 𝑎 = = 𝑝𝑟𝑖𝑐𝑒
  • 11. Andrew Ng Demand Prediction probability of being a top seller layer layer price shipping cost marketing material
  • 12. Andrew Ng Demand Prediction probability of being a top seller layer layer price shipping cost marketing material a a
  • 13. Andrew Ng Demand Prediction probability of being a top seller layer layer price shipping cost marketing material a a
  • 14. Andrew Ng Multiple hidden layers x input hidden layer hidden layer output layer hidden layer hidden layer hidden layer neural network architecture x a a
  • 16. Andrew Ng x = Face recognition
  • 17. Andrew Ng Face recognition x input output layer probability of being person ‘XYZ’ source: Convolutional Deep Belief Networks for Scalable Unsupervised Learning of Hierarchical Representations by Honglak Lee, Roger Grosse, Ranganath Andrew Y. Ng ⋮ ⋮ ⋮
  • 18. Andrew Ng probability of car detected source: Convolutional Deep Belief Networks for Scalable Unsupervised Learning of Hierarchical Representations by Honglak Lee, Roger Grosse, Ranganath Andrew Y. Ng Car classification output layer ⋮ ⋮ ⋮
  • 21. Andrew Ng x x 𝑤1 ,𝑏1 w2 ,𝑏2 w3 ,𝑏3 𝑎3 = 𝑔(w3 ∙ x + 𝑏3 ) 𝑔(𝑧) = 1 1 + 𝑒− 𝑧 Neural network layer 𝑎2 [1] = 𝑔(w2 [1] ∙ x + 𝑏2 [1] ) 𝑎1 [1] = 𝑔(w1 [1] ∙ x + 𝑏1 [1] ) layer 1 layer 2 layer 0 a[1] a[1] notation for layer numbering vector of activation values from layer 1
  • 22. Andrew Ng x 𝑤1 ,𝑏1 a Neural network layer a[1] 𝑎1 [1] = 𝑔(w1 [1] ∙ a[1] + 𝑏1 [1] ) 𝑔(𝑧) = 1 1 + 𝑒− 𝑧 layer 2 layer 1 a[1] 𝑎[2] a scalar value
  • 23. Andrew Ng x Neural network layer a[1] 𝑎[2] layer 1 layer 2 𝑖𝑠 𝑎 2 ≥ 0.5? ො 𝑦 = 1 ො 𝑦 = 0 predict category 1 or 0 (yes/no)
  • 24. More complex neural networks Neural Network Model
  • 25. Andrew Ng More complex neural network x input a[1] a[2] a[3] a[4] layer 1 layer 2 layer 3 layer 4 hidden layers layer 0 output layer
  • 26. Andrew Ng More complex neural network x input a[1] a[2] a[3] a[4] layer 1 layer 2 layer 3 layer 4 𝑤1 [3] ,𝑏1 [3] w2 [3] ,𝑏2 [3] w3 [3] ,𝑏3 [3] 𝑎3 [3] = 𝑔(w3 [3] ∙ a[2] + 𝑏3 [3] ) 𝑎2 [3] = 𝑔(w2 [3] ∙ a[2] + 𝑏2 [3] ) 𝑎1 [3] = 𝑔(w1 [3] ∙ a[2] + 𝑏1 [3] ) a[2] a[3]
  • 27. Andrew Ng Notation x input a[1] a[2] a[3] a[4] layer 1 layer 2 layer 3 layer 4 𝑤1 [3] ,𝑏1 [3] w2 [3] ,𝑏2 [3] w3 [3] ,𝑏3 [3] 𝑎3 [3] = 𝑔(w3 [3] ∙ a[2] + 𝑏3 [3] ) 𝑎2 [3] = 𝑔(w2 [3] ∙ a[2] + 𝑏2 [3] ) 𝑎1 [3] = 𝑔(w1 [3] ∙ a[2] + 𝑏1 [3] ) a[2] a[3] Question: Can you fill in the superscripts and subscripts for the second neuron?
  • 28. Andrew Ng Notation x input a[1] a[2] a[3] a[4] layer 1 layer 2 layer 3 layer 4 𝑤1 [3] ,𝑏1 [3] w2 [3] ,𝑏2 [3] w3 [3] ,𝑏3 [3] 𝑎3 [3] = 𝑔(w1 [3] ∙ a[2] + 𝑏1 [3] ) 𝑎1 [3] a[2] Activation value of layer 𝑙, unit(neuron) 𝑗 Parameters w & b of layer 𝑙, unit 𝑗 output of layer 𝑙 − 1 (previous layer) sigmoid x 𝑎2 [3] = 𝑔(w2 [3] ∙ a[2] + 𝑏2 [3] ) = 𝑔(w3 [3] ∙ a[2] + 𝑏3 [3] ) 𝑎2 [3] = 𝑔(w2 [3] ∙ a[2] + 𝑏2 [3] ) a[3] = 𝑔(w𝑗 [𝑙] ∙ a[𝑙−1] + 𝑏𝑗 [𝑙] ) 𝑎𝑗 [𝑙]
  • 29. Neural Network Model Inference: making predictions (forward propagation)
  • 30. Andrew Ng Handwritten digit recognition x output layer probability of being a handwritten ‘1’ 25 units 15 units a[1] ⋮ ⋮ a[1] a[2] a[3] 1 unit layer 1 layer 2 layer 3 Digit images label 0 1
  • 31. Andrew Ng Handwritten digit recognition x output layer 25 units 15 units a[2] ⋮ ⋮ a[1] a[2] a[3] 1 unit layer 1 layer 2 layer 3 Digit images label 0 1 probability of being a handwritten ‘1’
  • 32. Andrew Ng Handwritten digit recognition output layer probability of being a handwritten ‘1’ ⋮ ⋮ 25 units 15 units a[2] a[3] a[3] = 𝑔 w1 3 ∙ a 2 + 𝑏1 3 𝑖𝑠 𝑎1 3 ≥ 0.5? ො 𝑦 = 1 ො 𝑦 = 0 1 unit forward propagation a[1] x layer 1 layer 2 layer 3 𝑓(𝑥) = image is digit 1 image isn’t digit 1
  • 34. Andrew Ng Coffee roasting a[1] a[2] 𝑖𝑠 𝑎1 2 ≥ 0.5? ො 𝑦 = 1 ො 𝑦 = 0 x Temperature (Celsius) Duration (minutes)
  • 35. Andrew Ng a[1] a[2] x x = np.array([[200.0, 17.0]]) layer_1 = Dense(units=3, activation=‘sigmoid’) a1 = layer_1(x)
  • 36. Andrew Ng Build the model using TensorFlow a[1] a[2] layer_2 = Dense(units=1, activation=‘sigmoid’) a2 = layer_2(a1) x = np.array([[200.0, 17.0]]) layer_1 = Dense(units=3, activation=‘sigmoid’) a1 = layer_1(x) x
  • 37. Andrew Ng Build the model using TensorFlow 𝑖𝑠 𝑎1 2 ≥ 0.5? if a2 >= 0.5: yhat = 1 else: yhat = 0 ො 𝑦 = 1 ො 𝑦 = 0 layer_2 = Dense(units=1, activation=‘sigmoid’) a2 = layer_2(a1) x = np.array([[200.0, 17.0]]) layer_1 = Dense(units=3, activation=‘sigmoid’) a1 = layer_1(x) a[1] a[2] x
  • 38. Andrew Ng Model for digit classification x ⋮ ⋮ 25 units 15 units a[2] a[3] 1 unit x = np.array([[0.0,...245,...240...0]]) layer_1 = Dense(units=25, activation=‘sigmoid’) a1 = layer_1(x) a[1]
  • 39. Andrew Ng Model for digit classification x ⋮ ⋮ 25 units 15 units a[1] a[2] a[3] 1 unit x = np.array([[0.0,...245,...240...0]]) layer_1 = Dense(units=25, activation=‘sigmoid’) a1 = layer_1(x) layer_2 = Dense(units=15, activation=‘sigmoid’) a2 = layer_2(a1)
  • 40. Andrew Ng Model for digit classification x ⋮ ⋮ 25 units 15 units a[2] a[3] 1 unit x = np.array([[0.0,...245,...240...0]]) layer_1 = Dense(units=25, activation=‘sigmoid’) a1 = layer_1(x) layer_2 = Dense(units=15, activation=‘sigmoid’) a2 = layer_2(a1) layer_3 = Dense(units=1, activation=‘sigmoid’) a3 = layer_3(a2) a[1]
  • 41. Andrew Ng Model for digit classification x ⋮ ⋮ 25 units 15 units a[2] a[3] 1 unit x = np.array([[0.0,...245,...240...0]]) layer_1 = Dense(units=25, activation=‘sigmoid’) a1 = layer_1(x) layer_2 = Dense(units=15, activation=‘sigmoid’) a2 = layer_2(a1) if a3 >= 0.5: yhat = 1 else: yhat = 0 layer_3 = Dense(units=1, activation=‘sigmoid’) a3 = layer_3(a2) 𝑖𝑠 𝑎1 3 ≥ 0.5? ො 𝑦 = 1 ො 𝑦 = 0 a[1]
  • 43. Andrew Ng Feature vectors temperature (Celsius) duration (minutes) Good coffee? (1/0) 200.0 17.0 1 425.0 18.5 0 … … … x = np.array([[200.0, 17.0]]) [[200.0, 17.0]]
  • 44. Andrew Ng Note about numpy arrays 1 2 3 4 5 6 x = np.array([[1, 2, 3], [4, 5, 6]]) [[1, 2, 3], [4, 5, 6]] x = np.array([[0.1, 0.2], [-3.0, -4.0,], [-0.5, -0.6,], [7.0, 8.0,]]) [[0.1, 0.2], [-3.0, -4.0,], [-0.5, -0.6,], [7.0, 8.0,]] 2 x 3 4 x 2 1 x 2 2 x 1
  • 45. Andrew Ng Note about numpy arrays x = np.array([[200, 17]]) x = np.array([[200], [17]]) x = np.array([200,17]) 200 17 200 17 1 x 2 2 x 1
  • 46. Andrew Ng Feature vectors temperature (Celsius) duration (minutes) Good coffee? (1/0) 200.0 17.0 1 425.0 18.5 0 … … … x = np.array([[200.0, 17.0]]) [[200.0, 17.0]] 200.0 17.0 1 x 2
  • 47. Andrew Ng Activation vector a[1] a[2] x x = np.array([[200.0, 17.0]]) layer_1 = Dense(units=3, activation=‘sigmoid’) a1 = layer_1(x) tf.Tensor([[0.2 0.7 0.3]], shape=(1, 3), dtype=float32) a1.numpy() array([[1.4661001, 1.125196 , 3.2159438]], dtype=float32) 1 x 3 matrix
  • 48. Andrew Ng Activation vector a[1] a[2] x layer_2 = Dense(units=1, activation=‘sigmoid’) a2 = layer_2(a1) tf.Tensor([[0.8]], shape=(1, 1), dtype=float32) a2.numpy() array([[0.8]], dtype=float32) 1 x 1
  • 50. Andrew Ng What you saw earlier layer_2 = Dense(units=1, activation="sigmoid") a2 = layer_2(a1) x = np.array([[200.0, 17.0]]) layer_1 = Dense(units=3, activation="sigmoid") a1 = layer_1(x) a[1] a[2] x
  • 51. Andrew Ng Building a neural network architecture layer_2 = Dense(units=1, activation="sigmoid") layer_1 = Dense(units=3, activation="sigmoid") a[1] a[2] x model = Sequential([layer_1, layer_2]) model.fit(x,y) model.compile(...) x = np.array([[200.0, 17.0], [120.0, 5.0], [425.0, 20.0], [212.0, 18.0]) y = np.array([1,0,0,1]) model.predict(x_new) y 200 17 1 120 5 0 425 20 0 212 18 1 4 x 2
  • 52. Andrew Ng layer_1 = Dense(units=25, activation="sigmoid") Digit classification model x ⋮ ⋮ 25 units 15 units a[2] a[3] 1 unit a[1] layer_2 = Dense(units=15, activation="sigmoid") model = Sequential([layer_1, layer_2, layer_3] model.fit(x,y) model.compile(...) x = np.array([[0..., 245, ..., 17], [0..., 200, ..., 184]) y = np.array([1,0]) layer_3 = Dense(units=1, activation="sigmoid") model.predict(x_new)
  • 53. Andrew Ng Digit classification model x ⋮ ⋮ 25 units 15 units a[2] a[3] 1 unit a[1] model = Sequential([ Dense(units=25, activation="sigmoid"), Dense(units=15, activation="sigmoid"), Dense(units=1, activation="sigmoid")]) model.compile(...) x = np.array([[0..., 245, ..., 17], [0..., 200, ..., 184]) y = np.array([1,0]) model.fit(x,y) model.predict(x_new)
  • 54. Neural network implementation in Python Forward prop in a single layer
  • 55. Andrew Ng forward prop (coffee roasting model) 𝑎1 [1] = 𝑔(w1 [1] ∙ x + 𝑏1 [1] ) x = np.array([200, 17]) w1_1 = np.array([1, 2]) b1_1 = np.array([-1]) z1_1 = np.dot(w1_1,x)+ b a1_1 = sigmoid(z1_1) 𝑎2 [1] = 𝑔(w2 [1] ∙ x + 𝑏2 [1] ) w1_2 = np.array([-3, 4]) b1_2 = np.array([1]) z1_2 = np.dot(w1_2,x)+b a1_2 𝑎3 [1] = 𝑔(w3 [1] ∙ x + 𝑏3 [1] ) w1_3 = np.array([5, -6]) b1_3 = np.array([2]) z1_3 = np.dot(w1_3,x)+b a1_3 = sigmoid(z1_3) 𝑎1 [2] = 𝑔(w1 [2] ∙ a[1] + 𝑏1 [2] ) b2_1 = np.array([3]) z2_1 = np.dot(w2_1,a1)+b2_1 a2_1 = sigmoid(z1_1) w2_1 = np.array([-7, 8]) a[1] a[2] x 𝑤1 [1] ,𝑏1 [1] w2 [1] ,𝑏2 [1] w3 [1] ,𝑏3 [1] 𝑤1 [2] ,𝑏1 [2] a1 = np.array([a1_1, a1_2, a1_3]) = sigmoid(z1_2) w2_1
  • 56. Neural network implemenation in Python General implementation of forward propagation
  • 57. Andrew Ng Forward prop in NumPy def dense(a_in,W,b, g): units = W.shape[1] a_out = np.zeros(units) for j in range(units): w = W[:,j] z = np.dot(w,a_in) + b[j] a_out[j] = g(z) return a_out def sequential(x): a1 = dense(x,W1,b1,g) a2 = dense(a1,W2,b2,g) a3 = dense(a2,W3,b3,g) a4 = dense(a3,W4,b4,g) f_x = a4 return f_x 𝑤1 [1] = 1 2 w2 [1] = −3 4 w3 [1] = 5 −6 𝑏1 [𝑙] = −1 𝑏2 [𝑙] = 1 𝑏3 [𝑙] = 2 𝑤1 [1] ,𝑏1 [1] w2 [1] ,𝑏2 [1] w3 [1] ,𝑏3 [1] a[𝑙] x b = np.array([-1, 1, 2]) a_in = np.array([-2, 4]) W = np.array([ [1, -3, 5] [2, 4, -6]]) a[0] = x
  • 58. Speculations on artificial general intelligence (AGI) Is there a path to AGI?
  • 59. Andrew Ng AI E.g., smart speaker, self-driving car, web search, AI in farming and factories Do anything a human can do ANI (artificial narrow intelligence) AGI (artificial general intelligence)
  • 60. Andrew Ng image source: https://biologydictionary.net/sensory-neuron/ inputs outputs Simplified mathematical model of a neuron inputs outputs Biological neuron
  • 61. Andrew Ng Neural network and the brain Can we mimic the human brain? x 𝑓(x) vs We have (almost) no idea how the brain works
  • 62. Andrew Ng The ”one learning algorithm” hypothesis Auditory cortex learns to see Auditory cortex [Roe et al., 1992]
  • 63. Andrew Ng The ”one learning algorithm” hypothesis Somatosensory cortex learns to see Somatosensory cortex [Metin & Frost, 1989]
  • 64. Andrew Ng Sensor representations in the brain Seeing with your tongue Human echolocation (sonar) Haptic belt: Direction sense Implanting a 3rd eye [BrainPort; Welsh & Blasch, 1997; Nagel et al., 2005; Constantine-Paton & Law, 2009]
  • 65. Vectorization (optional) How neural networks are implemented efficiently
  • 66. Andrew Ng For loops vs. vectorization def dense(a_in,W,b): a_out = np.zeros(units) for j in range(units): w = W[:,j] z = np.dot(w,x) + b[j] a[j] = g(z) return a def dense(A_in,W,B): Z = np.matmul(A_in,W) + B A_out = g(Z) return A_out X = np.array([[200, 17]]) W = np.array([[1, -3, 5], [-2, 4, -6]) B = np.array([[-1, 1, 2]]) [[1,0,1]] x = np.array([200, 17]) W = np.array([[1, -3, 5], [-2, 4, -6]]) b = np.array([-1, 1, 2]) [1,0,1]
  • 68. Andrew Ng Dot products 1 2 ∙ 3 4 𝑧 = a ∙ w ↑ a ↓ ∙ ↑ w ↓ ↑ w ↓ in general example vector vector multiplication a𝑻 = 1 2 ← a𝑻 → transpose a = 1 2 𝑧 = a𝑻w
  • 69. Andrew Ng Vector matrix multiplication → w1 → w2 [ ← → a 𝑻 → ] 𝐙 = → a 𝑻 𝐖 𝐙 = [ → a 𝑻→ w1 𝑎𝑻→ w2] 𝐙 = [11 17] (1 ∗ 3) + (2 ∗ 4) (1 ∗ 5) + (2 ∗ 6) → a 𝑻 = [1 2] → a = [ 1 2] 𝐖 = [ 3 5 4 6]
  • 70. Andrew Ng ← → a 𝑇 1 → ← → a 𝑇 2 → matrix matrix multiplication = [ 11 17 − 11 − 17] 𝐖 = [ 3 5 4 6] → w1 → w2 𝐀𝑻 = [ 1 2 − 1 − 2] 𝐀 = [ 1 − 1 2 − 2] = → a 𝑇 1 → w1 → a 𝑇 1 → w2 → a 𝑇 2 → w1 → a 𝑇 2 → w2 𝐙 = 𝐀𝑻 𝐖 =
  • 72. Andrew Ng Matrix multiplication rules 𝐀 = 1 −1 0.1 2 −2 0.2 𝐖 = 3 5 7 9 4 6 8 0 𝒁 = 𝐀𝑻 𝐖 = 𝐀𝑻 = 1 2 −1 −2 0.1 0.2
  • 73. Andrew Ng Matrix multiplication rules 𝐀 = 1 −1 0.1 2 −2 0.2 𝐖 = 3 5 7 9 4 6 8 0 𝐀𝑻 = 1 2 −1 −2 0.1 0.2 𝒁 = 𝐀𝑻 𝐖 =
  • 74. Andrew Ng 𝒁 = 𝐀𝑻 𝐖 = 11 17 23 9 −11 −17 −23 −9 1.1 1.7 2.3 0.9 Matrix multiplication rules 𝐀 = 1 −1 0.1 2 −2 0.2 𝐖 = 3 5 7 9 4 6 8 0 𝐀𝑻 = 1 2 −1 −2 0.1 0.2
  • 75. Andrew Ng 𝒁 = 𝐀𝑻 𝐖 = 11 17 23 9 −11 −17 −23 −9 1.1 1.7 2.3 0.9 Matrix multiplication rules 𝐀 = 1 −1 0.1 2 −2 0.2 𝐖 = 3 5 7 9 4 6 8 0 𝐀𝑻 = 1 2 −1 −2 0.1 0.2
  • 77. Andrew Ng Matrix multiplication in NumPy Z = np.matmul(AT,W) A=np.array([1,-1,0.1], [2,-2,0.2]]) AT=np.array([1,2], [-1,-2], [0.1,0.2]) AT=A.T W=np.array([3,5,7,9], [4,6,8,0]) Z = AT @ W [[11,17,23,9], [-11,-17,-23,-9], [1.1,1.7,2.3,0.9] ] 𝒁 = 𝐀𝑻 𝐖 = 11 17 23 9 −11 −17 −23 −9 1.1 1.7 2.3 0.9 𝐀 = 1 −1 0.1 2 −2 0.2 𝐖 = 3 5 7 9 4 6 8 0 𝐀𝑻 = 1 2 −1 −2 0.1 0.2
  • 78. Andrew Ng Dense layer vectorized def dense(AT,W,b,g): z = np.matmul(AT,W) + b a_out = g(z) return a_out AT = np.array([[200, 17]]) W = np.array([[1, -3, 5], [-2, 4, -6]) b = np.array([[-1, 1, 2]]) [[1,0,1]] 𝐀𝑻 = 200 17 𝐖 = 1 −3 5 −2 4 −6 Ԧ 𝐛 = −1 1 2 𝐙 = 𝐀𝑻 𝐖 + 𝐁 𝐀 = g(𝐙) 1 0 1 165 −531 900 𝐀[1] 𝐀[2] 𝐀𝑻 𝑤1 [1] ,𝑏1 [1] w2 [1] ,𝑏2 [1] w3 [1] ,𝑏3 [1] 𝑧1 [1] 𝑧3 [1] 𝑧2 [1]