You are on page 1of 5

Basics of Neural

Network Programming

Vectorizing Logistic
deeplearning.ai
Regression
Vectorizing Logistic Regression
𝑧 (1) = 𝑤 𝑇 𝑥 (1) + 𝑏 𝑧 (2) = 𝑤 𝑇 𝑥 (2) + 𝑏 𝑧 (3) = 𝑤 𝑇 𝑥 (3) + 𝑏
𝑎(1) = 𝜎(𝑧 (1) ) 𝑎(2) = 𝜎(𝑧 (2) ) 𝑎(3) = 𝜎(𝑧 (3) )

Andrew Ng
Basics of Neural
Network Programming

Vectorizing Logistic
deeplearning.ai Regression’s Gradient
Computation
Vectorizing Logistic Regression

Andrew Ng
Implementing Logistic Regression
J = 0, d𝑤1 = 0, d𝑤2 = 0, db = 0
for i = 1 to m:
𝑧 (𝑖) = 𝑤 𝑇 𝑥 (𝑖) + 𝑏
𝑎(𝑖) = 𝜎(𝑧 (𝑖) )
𝐽 += − 𝑦 (𝑖) log 𝑎 𝑖 + (1 − 𝑦 𝑖 ) log(1 − 𝑎 𝑖 )
d𝑧 (𝑖) = 𝑎(𝑖) −𝑦 (𝑖)
(𝑖)
d𝑤1 += 𝑥1 d𝑧 (𝑖)
(𝑖)
d𝑤2 += 𝑥2 d𝑧 (𝑖)
db += d𝑧 (𝑖)
J = J/m, d𝑤1 = d𝑤1 /m, d𝑤2 = d𝑤2 /m
db = db/m
Andrew Ng

You might also like