【c1w3】- 吴恩达深度学习作业总结

【c1w3】- 吴恩达深度学习作业总结

0.总结

初始化参数 parameters-{W1,b1,W2,b2}
进行迭代
	前向传播
    计算损失函数
    反向传播
    参数更新(parameters)
返回参数 parameters

1.对于隐藏层为4(可以自己更改)模型

【c1w3】- 吴恩达深度学习作业总结

1.前向传播

z[1](i)=W[1]x(i)+b[1](i)a[1](i)=tanh(z[1](i))z[2](i)=W[2]a[1](i)+b[2](i)y^(i)=a[2](i)=σ(z[2](i)) \begin{aligned} &z^{[1] (i)} = W^{[1]} x^{(i)} + b^{[1] (i)} \\ &a^{[1] (i)} = \tanh(z^{[1] (i)}) \\ &z^{[2] (i)} = W^{[2]} a^{[1] (i)} + b^{[2] (i)} \\ &\hat{y}^{(i)} = a^{[2] (i)} = \sigma(z^{ [2] (i)}) \end{aligned}

####2.损失函数

J=1mi=0m(y(i)log(a[2](i))+(1y(i))log(1a[2](i))) J = - \frac{1}{m} \sum\limits_{i = 0}^{m} \large\left(\small y^{(i)}\log\left(a^{[2] (i)}\right) + (1-y^{(i)})\log\left(1- a^{[2] (i)}\right) \large \right) \small

3.反向传播

【c1w3】- 吴恩达深度学习作业总结

4.参数更新

θ=θαJθ \theta = \theta - \alpha \frac{\partial J }{ \partial \theta }

2.预测

利用之前存储的值,再进行一次前向传播

前向传播(得到A2)
阈值判断

predictions=yprediction=1activation > 0.5={1if activation>0.50otherwise predictions = y_{prediction} = \mathbb 1 \text{{activation > 0.5}} = \begin{cases} 1 & \text{if}\ activation > 0.5 \\ 0 & \text{otherwise} \end{cases}

1 .难点说明

1.导数

1-sigmoid

函数——f(z)=1/(1+exp(z))f(z) = 1 / (1 + exp(-z))

导数——f(z)=f(z)(1f(z))\mathrm{f}(\mathrm{z})^{\prime}=\mathrm{f}(\mathrm{z})(1-\mathrm{f}(\mathrm{z}))

2-tanh

函数——f(z)=tanh(z)f(z)=\tanh (z)

导数——f(z)=1(f(z))2f(z)^{\prime}=1-(f(z))^{2}

2.np.round()

返回浮点数 x 的四舍五入

可以用于神经网络中的判断

predictions=yprediction=1activation > 0.5={1if activation>0.50otherwise predictions = y_{prediction} = \mathbb 1 \text{{activation > 0.5}} = \begin{cases} 1 & \text{if}\ activation > 0.5 \\ 0 & \text{otherwise} \end{cases}

3.参数说明

x - (输入大小,样本数)  (2,400)
Y - (输出大小,样本数)  (1,400)

W - (这层神经元个数,前一层神经元个数(特征数))  
b - (这层神经元个数,1)