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