第二周:神经网络基础

logistic函数

预测概率yhat = w^t * x +b,为了保证概率为1,使用sigmoid函数进行修正,
yhat = 1/(1+e-z)(wt+b)

损失函数和成本函数

利用loss function和cost function 可以来体现预测效果
(how well your parameters w and b are doing on the training set.)
loss function是单个的y的预测效果
公式: 损失函数
cost fuction 是对整体的预测情况进行表示,公式如下:
成本函数

w和b的调试(梯度下降法)

在这里插入图片描述成本函数J(w,b)是一个凸函数,要调w和b使成本函数达到最小值

在这里插入图片描述

反向传播和正向传播(导数)

一个数学公式,从左到右的进行计算即为正向传播,从右向左来求导数,为反向传播。
在程序中,也许关注的使f的最终的导数,用dvar表示。

广播

广播听起来感觉很高大上,但其实是一种矩阵的扩展。
例如,在计算矩阵A[1,2,3,4]*100时,是将100展开为【100,100,100,100】来计算
另外,在python中要尽量减少for循环,使用np.来计算矩阵。

具体实现

1、数据预处理
-Figure out the dimensions and shapes of the problem (m_train, m_test, num_px, …)
-Reshape the datasets such that each example is now a vector of size (num_px * num_px * 3, 1)
-“Standardize” the data
2、神经网络学习

  • Initialize the parameters of the model
  • Learn the parameters for the model by minimizing the cost
  • Use the learned parameters to make predictions (on the test set)
  • Analyse the results and conclude

猜你喜欢

转载自blog.csdn.net/qq_41380950/article/details/88381167