Andrew ng 深度學習課程筆記

雨落雲風發表於2018-01-27

課程一 神經網路和深度學習

1. 深度學習概論

1.2 什麼是神經網路

從Housing Price Prediction 講起 => regression 迴歸可以看成一個簡單的單層,一個神經元的神經網路

1.3 用神經網路進行監督學習

image

1.4 為什麼深度學習會興起

  • Data
  • Computation
  • Algorithms: 比如sigmod -> relu 使得計算gradient descent更快

image

2. 神經網路基礎

2.1 二分分類

some notations ...

2.2 logistic 迴歸

logistic 迴歸就是一個淺層(shallow, 實際上一個hidden layer也沒有,只有一個output layer)神經網路

Give\ x,\ want\ \hat y = P(y=1|x);\  (0<=y<=1)

parameters:w\in \mathbb{R},b\in \mathbb{R}

Output:\hat y=\sigma(w^tx+b); find\ w,b

\sigma(z)=\frac{1}{1+e^{-z}}
複製程式碼

2.3 logistic迴歸損失函式

使用這個損失函式便於計算gradient descent

Loss(Error)\ Function : L(\hat y,y) = - (y\log\hat y + (1-y)\log(1-\hat y)) 

Cost\ Function:  J(w,b) = 1/m *\sum_{i=1}^m  L(\hat y^i,y^i) = -\frac{1}{m}*\sum_{i=1}^m(y^i\log\hat y^i + (1-y^i)\log(1-\hat y^i)) 

複製程式碼

2.4 梯度下降法

w := w - \alpha \frac{dJ(w,b)}{dw};\  (\alpha:learning\ rate)

b := b - \alpha \frac{dJ(w,b)}{db}
複製程式碼

2.7 計算圖

反向傳播:其實有點類似dp演算法,後往前算gradient descent, 這樣有些算的結果可以複用,計算效率大大提高

image

2.9 logistic迴歸中的梯度下降

\text {圖裡面的a是之前的} \hat y
複製程式碼

image

分數求導:結果的分子=原式的分子求導乘以原式的分母-原式的分母求導乘以原式的分子,結果的分母=原式的分母的平方。

2.10 logistic迴歸on m個examples

image

2.11 向量化

向量化計算更高效

import numpy as np
import time

a = np.random.rand(1000000)
b = np.random.rand(1000000)
tic = time.time()
c = np.dot(a, b)
print("cost " + str((time.time() - tic)*1000) + "ms")
複製程式碼

2.13 向量化的logistic迴歸

image

2.15 python中的廣播

2.16 python/numpy中的向量說明

不要使用秩為1的向量,顯式使用1*n或者n*1的向量, 使用reshape和assert來確保維度符合預期

import numpy as np
a = np.random.randn(5) #do not use 
print("a:",a.shape,"\n", a)
b = np.random.randn(5, 1)
print("b:",b.shape,"\n", b)
c = np.random.randn(1, 5)
print("c:",c.shape,"\n", c)

a = a.reshape(5, 1)
assert(a.shape == (5, 1))
複製程式碼

3. 淺層神經網路

3.1 神經網路概覽

image

3.2 神經網路表示

image

3.5 向量化實現的解釋

image

3.6 啟用函式

image

3.7 為什麼使用非線性的啟用函式

如果是線性的 經過幾層之後還是線性的,多層就沒有意義了

3.8 啟用函式的導數

image
image
image

3.9 啟用函式的導數

image

image

3.11 隨機初始化

多神經元為何W不能初始化為0矩陣

4. 深層神經網路

4.1 深層神經網路

image

4.3 核對矩陣的維數

image

image

4.7 引數VS超引數

image

課程二 改善深層神經網路:超引數除錯、正則化以及優化

1. 深度學習的實用層面

1.1 訓練、開發、測試集

1.2 偏差、方差

image
image

1.4 Regularization

image
image

lamda 很大會發生什麼:

image

1.6 Drop Out Regularization

1.8 其他Regularization方法

early stopping

1.9 Normalizing inputs

image

image

1.10 vanishing/exploding gradients

image

1.11 權重初始化

image

1.13 Gradient Check

image

1.14 Gradient Check Implementation Notes

image

2. 優化演算法

2.1 Mini-batch gradient descent

batch-size 要適配CPU/GPU memory

2.3 Exponentially weighted averages

image

移動平均可撫平短期波動,將長線趨勢或週期顯現出來。數學上,移動平均可視為一種卷積。

Bias correction

image

2.6 Gradient Descent with Momentum

image

2.7 RMSprop

image

2.8 Adam優化演算法

Momentum + RMSprop

image

2.9 Learning rate decay

逐步減小Learning rate的方式

2.10 區域性最優的問題

在高維空間,容易遇到saddle point但是local optima其實不容易遇到

plateaus是個問題,learning會很慢,但是類似adam的方法能減輕這個問題

3. 超引數除錯、batch正則化和程式框架

3.1 搜尋超引數

image

  1. Try random values: don't use a grid
  2. Coarse to fine

image

3.4 Batch Normalization

一個問題,在迴歸中可以normalization在神經網路中可否做類似的事情

image

通過lamda和beta可以控制mean和variance

image

image

image

3.6 Batch Normalization為什麼有效

  1. By normlization values to similar range of values, it speed up learning
  2. Batch normlization reduces the problem of input values(對於每一層) changing
  3. Has a slight regulazation effect (like dropout, it adds some noice to each hidden layer's activations)

3.7 Batch Normalization at test time

使用訓練中加權指數平均算出來的mean,variance來test

image

3.8 Softmax regression

多類,而不是二類。generazation of logistic regression.

image

3.10 深度學習框架

課程三 結構化機器學習專案

1. 機器學習(ML)策略(1)

1.1 為什麼是ML策略

1.2 正交化

  1. Fit training set well in cost function
  • If it doesn’t fit well, the use of a bigger neural network or switching to a better optimization algorithm might help.
  1. Fit development set well on cost function
  • If it doesn’t fit well, regularization or using bigger training set might help.
  1. Fit test set well on cost function
  • If it doesn’t fit well, the use of a bigger development set might help
  1. Performs well in real world
  • If it doesn’t perform well, the development test set is not set correctly or the cost function is not evaluating the right thing

1.3 單一數字評估指標

關於accuracy/precision/recall/F1

image
image

1.4 滿足和優化指標

1.5 訓練/開發/測試集劃分

1.6 開發集合測試集的大小

1.7 什麼時候該改變開發/測試集和指標

1.8 為什麼是人的表現

1.9 可避免偏差

1.10 理解人的表現

1.11 超過人的表現

1.12 改善你的模型的表現

image

2. 機器學習(ML)策略(2)

2.1 進行誤差分析

2.2 清楚標註錯誤的資料

2.3 快速搭建你的第一個系統,並進行迭代

2.4 在不同的劃分上進行訓練並測試

2.5 不匹配資料劃分的偏差和方差

2.6 定位資料不匹配

2.7 遷移學習

2.8 多工學習

2.9 什麼是端到端的深度學習

2.10 是否要使用端到端的深度學習

課程四 卷積神經網路

1. 卷積神經網路

1.1 計算機視覺

真實處理的圖片很大->卷積神經網路

1.2 邊緣檢測示例

filter(kernel)的選擇有很多種,或者把filter本身當作引數來學習.

image

1.4 Padding

image

1.5 卷積步長

1.6 Convolutions over volumes

image

1.7 單層卷積網路

image

1.8 簡單卷積網路示例

image

1.9 池化層

image

1.10 卷積神經網路示例

image
image

1.11 為什麼使用卷積?

image

2. 深度卷積網路:例項探究

2.1 為什麼要進行例項探究

  • Classic networks:
    • LeNet-5
    • AlexNet
    • VGG
  • ResNet
  • Inception

2.2 經典網路

介紹了三種經典模型:LeNet-5,AlexNet,VGG-16

2.3 殘差網路(ResNets, Residual Networks)

image

2.4 殘差網路為什麼有用?

2.5 網路中的網路以及 1×1 卷積

1×1 卷積可以壓縮或者保持,增加輸入層的通道(channel)數量.

image

2.6 谷歌 Inception 網路簡介

2.7 Inception 網路

Inception module -> Inception network

image
image

2.8 使用開源的實現方案

2.9 遷移學習

使用他人的模型作為initalization(選擇freeze some layers)訓練

image

2.10 資料擴充

  • mirroring
  • random cropping
  • rotating,shearing,local warping...
  • color shifting

2.11 計算機視覺現狀

image

3. 目標檢測

3.1 目標定位

image

3.2 特徵點檢測

image

3.3 目標檢測

先crop圖片訓練模型 + slide-window =>計算成本很高

image

3.4 卷積的滑動視窗實現

一次計算,其實沒有slide,比傳統的slide-window方式高效很多

image

3.5 Bounding Box預測

YOLO: grid + 3.1中的演算法的卷積實現.

image
image

3.6 交併比

IOU - Intersection over Union = SizeOfIntersection/ SizeOfUnion

3.7 非極大值抑制

image

3.8 Anchor Boxes

image

3.9 YOLO 演算法

3.10 RPN網路

image

4. 特殊應用:人臉識別和神經風格轉換

4.1 什麼是人臉識別?

image

4.2 One-Shot 學習

image

4.3 Siamese 網路

image

4.4 Triplet 損失

image
image
image

4.5 面部驗證與二分類

image

4.6 什麼是神經風格轉換?

4.7 什麼是深度卷積網路?

image

4.8 代價函式

4.9 內容代價函式

4.10 風格代價函式

核心是maximize 各個channel 的 correlation

image

image

4.11 一維到三維推廣

相關文章