Deep Neural Networks - Building blocks of deep neural networks

Take the deep NN of figure-1 as the example:

Figure-1

 Following figure-2 shows the building blocks of this deep NN while generalized the figure for NN with L layers:

Figure-2
  • Forward and backward propagation for single example x:

Forward propagation:

Input a^{[l-1]}, output a^{[l]}, cached z^{[l]}:

z^{[l]}=W^{[l]}a^{[l-1]}+b^{[l]}

a^{[l]}=g^{[l]}(z^{[l]})

The initial input is vector x

Backward propagation:

Input da^{[l]}, output da^{[l-1]}, dW^{[l]}, db^{[l]}:

dz^{[l]}=da^{[l]}*g^{[l]'}(z^{[l]})

dW^{[l]}=dz^{[l]}a^{[l-1]^{T}}

db^{[l]}=dz^{[l]}

da^{[l-1]}=W^{[l]^{T}}dz^{[l]}

The initial input is da^{[L]}=-\frac{y}{a}+\frac{(1-y)}{(1-a)}=-\frac{y}{\hat{y}}+\frac{(1-y)}{(1-\hat{y})}

A side notes here is how to calculate dz^{[l]} from previous layer dz^{[l+1]}:

dz^{[l]}=W^{[l+1]^{T}}dz^{[l+1]}*g^{[l]'}(z^{[l]})

  • Forward and backup propagation for m examples X:

Forward propagation:

Input A^{[l-1]}, output A^{[l]}, cached Z^{[l]}

Z^{[l]}=W^{[l]}A^{[l-1]}+b^{[l]}

A^{[l]}=g^{[l]}(Z^{[l]})

The initial input is X like

Backward propagation:

Input dA^{[l]}, output dA^{[l-1]}, dW^{[l]}, db^{[l]}

dZ^{[l]}=dA^{[l]}*g^{[l]'}(Z^{[l]})

dW^{[l]}=\frac{1}{m}dZ^{[l]}A^{[l-1]^{T}}

db^{[l]}=\frac{1}{m}np.sum(dZ^{[l]}, axis=1, keepdims=True)

dA^{[l-1]}=W^{[l]^{T}}dZ^{[l]}

The initial input is:

dA^{[L]}=\begin{bmatrix} -\frac{y^{(1)}}{a^{(1)}}+\frac{(1-y^{(1)})}{(1-a^{(1)})} & -\frac{y^{(2)}}{a^{(2)}}+\frac{(1-y^{(2)})}{(1-a^{(2)})} & ... & -\frac{y^{(m)}}{a^{(m)}}+\frac{(1-y^{(m)})}{(1-a^{(m)})} \end{bmatrix}

<end>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值