SlideShare a Scribd company logo
1 of 66
TensorFlow深度學習快速上手班
二、深度學習
By Mark Chang
• 深度學習的原理
• 模型選擇與參數調整
• 多層感知器實作
深度學習的原理
機器學習
監督式學習
Supervised Learning
非監督式學習
Unsupervised Learning
增強式學習
Reinforcement Learning
深度學習
Deep Learning
深度學習
• 一種機器學習的方法
• 用電腦模擬人腦神經系統構造
• 讓電腦學會人腦可做的事
神經元與動作電位
http://humanphisiology.wikispaces.com/file/view/neuron.png/2164
60814/neuron.png
http://upload.wikimedia.org/wikipedia/commons/thumb/
4/4a/Action_potential.svg/1037px-
Action_potential.svg.png
模擬神經元
nW1
W2
x1
x2
b
Wb
y
nin
nout
(0,0)
x2
x1
模擬神經元
1
0
二元分類:AND Gate
x1 x2 y
0 0 0
0 1 0
1 0 0
1 1 1
(0,0)
(0,1) (1,1)
(1,0)
0
1
n20
20
b
-30
yx
1
x
2
XOR Gate ?
(0,0)
(0,1) (1,1)
(1,0)
0
0
1
x1 x2 y
0 0 0
0 1 1
1 0 1
1 1 0
二元分類:XOR Gate
n
-20
20
b
-10
y
(0,0)
(0,1) (1,1)
(1,0)
0
1
(0,0)
(0,1) (1,1)
(1,0)
1
0
(0,0)
(0,1) (1,1)
(1,0)
0
0
1
n1
20
20
b
-30
x
1
x
2
n2
20
20
b
-10
x
1
x
2
x1 x2 n1 n2 y
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0
類神經網路
x
y
n11
n12
n21
n22W12,y
W12,x
b
W11,y
W11,bW12,b
b
W11,x W21,11
W22,12
W21,12
W22,11
W21,bW22,b
z1
z2
Input
Layer
Hidden
Layer
Output
Layer
視覺認知
http://www.nature.com/neuro/journal/v8/n8/images/nn0805-975-F1.jpg
訓練類神經網路
• 用隨機值初始化模型參數w
• Forward Propagation
– 用目前的模型參數計算出答案
• 計算錯誤量(用Error Function)
• Backward Propagation
– 用錯誤量來修正模型
長期記憶
http://www.pnas.org/content/102/49/17846/F7.large.jpg
訓練類神經網路
訓練資料 機器學習模型 輸出值
正確答案
對答案
如果答錯了,
要修正模型
初始化 Forward
Propagatio
n
Error
Function
Backward
Propagatio
n
初始化
• 將所有的W隨機設成-N~N之間的數
• 每層之間W的值都不能相同
x
y
n11
n12
n21
n22W12,y
W12,x
b
W11,y
W11,bW12,b
b
W11,x W21,11
W22,12
W21,12
W22,11
W21,bW22,b
z
1
z
2
Lk-1:上一層的大小
Lk :該層的大小
Forward Propagation
Forward Propagation
Error Function
n21
n22
z1
z2
w1
w0
Gradient Descent
Backward Propagation
Backward Propagation
Backward Propagation
Backward Propagation
Backward Propagation
Backward Propagation
Backward Propagation
Backward Propagation
http://cpmarkchang.logdown.com/posts/277349-neural-network-backward-
propagation
模型選擇與參數調整
模型種類
• 非線性轉換
Sigmoid:
nW1
W2
x1
x2
b Wb
tanh:
ReLU:
模型種類
• Hidden Layer
較小的Hidden Layer 較大的Hidden Layer
多層Hidden Layer單層Hidden Layer
模型複雜度
• 模型中的參數個數(weight和bias的個數)
模型複雜度低 高
訓練不足與過度訓練
Tensorflow Playground
http://playground.tensorflow.org/
資料分佈
訓練適度 訓練不足 訓練過度
訓練不足(Underfitting)
• 原因:
– Learning Rate 太大或太
小
– 訓練時間太短
– 模型複雜度不夠
t
過度訓練(Overfitting)
• 原因:
– 雜訊太多
– 訓練資料太少
– 訓練時間太長
– 模型複雜度太高
t
驗證資料(Validation Data)
訓練資料
模型 1
測試資料 最後結果
資料集
驗證資料
模型選擇
參數選擇
時間控制
模型 2
……
交叉驗證(Cross Validation)
訓練資料驗證資料
訓練資料
訓練資料
驗證資料
驗證資料
第一回
第二回
第N回
……
解決方式
• 訓練不足
– 調整Learning Rate
– 增加訓練時間
– 增加模型複雜度
• 訓練過度
– 增加訓練資料
– 減少雜訊
– 減少訓練時間
– 減少模型複雜度
調整Learning Rate
• 調整Learning Rate數值
Learning
Rate
適中
Learning
Rate
過小
Learning
Rate
過大
調整Learning Rate
• 動態調整Learning Rate:
– AdagradOptimizer
– RMSPropOptimizer
– ……
調整訓練時間
• Early Stop
Validation
LossTraining Loss
停止訓練
t
調整模型複雜度
• 調整Hidden Layer的寬度或層數
• Regularization
• Dropout
Hidden Layer寬度
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0.5
0 1 2 3 4 5 6 7 8 9
Validation Loss
Training Loss
最適寬度
模型複雜度低 高
Loss
寬度
Regularization
• 將weights的平方和加到cost function中
• 可使weights的絕對值不要變得太大
• 可降低模型複雜度
Cost Function:
λ越大,則模型複雜度越低
Regularization
最適λ值
模型複雜度 低高
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0.01 0.1 1
Validation Loss
Training Loss
Loss
λ
Dropout
• 訓練時,隨機將Hidden Layer的神經元拿掉
• 可降低模型複雜度
• ex: 25%的Dropout Rate
Dropout
• 測試時,用所有的神經元來測試。
– 將所有的weight乘上 (1 – dropout_rate)
Dropout
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0.5
0 0.2 0.4 0.6 0.8 1
Validation
Error
Training Error
最適dropout rate
1- dropout rate
Error
模型複雜度低 高
模型選擇與參數調整實作
• Tensorflow Playground
– http://playground.tensorflow.org/
模型選擇與參數調整實作
• 訓練不足(UnderFitting)
模型選擇與參數調整實作
• 過度訓練(OverFitting)
多層感知器實作
多層感知器實作
https://github.com/ckmarkoh/ntc_deeplearning_tensorflow/bl
ob/master/sec2/multilayer_perceptron.ipynb
MNIST
• 數字識別
• 多元分類:0~9
https://www.tensorflow.org/versions/r0.7/images/MNIST.png
模型
• 多層感知器
Input Layer
Size:784
Hidden Layer
Size:200
Output Layer
Size:10
Computational Graph
x_ = tf.placeholder(tf.float32, [None, 784], name="x_")
y_ = tf.placeholder(tf.float32, [None, 10], name="y_")
# input -> Hidden
W1 = tf.Variable(tf.truncated_normal([784,200], stddev=0.1), name="W1")
b1 = tf.Variable(tf.zeros([200]), name="b1")
h1 = tf.nn.sigmoid(tf.matmul(x_, W1) + b1)
# Hidden -> Output
W2 = tf.Variable(tf.truncated_normal([200,10], stddev=0.1), name="W2")
b2 = tf.Variable(tf.zeros([10]), name="b2")
y = tf.nn.softmax(tf.matmul(h1, W2) + b2)
cross_entropy = -tf.reduce_sum(y_ * tf.log(y))
optimizer = tf.train.GradientDescentOptimizer(0.01)
trainer = optimizer.minimize(cross_entropy)
init = tf.initialize_all_variables()
Layer 1
W1 = tf.Variable(tf.truncated_normal([784,200], stddev=0.1), name="W1”)
0
1000
2000
3000
4000
5000
6000
7000
-0.2 0.20
Layer 1
W1 = tf.Variable(tf.truncated_normal([784,200], stddev=0.1), name="W1")
b1 = tf.Variable(tf.zeros([200]), name="b1")
h1 = tf.nn.sigmoid(tf.matmul(x_, W1) + b1)
W1
x
b1
h1
n
784
n
200
200
200
784
× + =
Layer 2
w
b
h1
n
10
10
200
200× + =
y
10
n
W2 = tf.Variable(tf.truncated_normal([200,10], stddev=0.1), name="W2")
b2 = tf.Variable(tf.zeros([10]), name="b2")
y = tf.nn.softmax(tf.matmul(h1, W2) + b2)
Regularization
lambda_ = tf.placeholder(tf.float32, name="lambda")
regularizer = tf.reduce_sum(tf.square(W1))
+tf.reduce_sum(tf.square(W2))
cost = cross_entropy + lambda_*regularizer
Cost Function:
Regularization
https://github.com/ckmarkoh/ntc_deeplearning_tensorflow/bl
ob/master/sec2/regularization.ipynb
dropout
keep_prob = tf.placeholder(tf.float32, name="keep_prob")
h1_drop = tf.nn.dropout(h1, keep_prob)
y = tf.nn.softmax(tf.matmul(h1_drop, W2) + b2)
1
0
1
0
Dropout
Mask
dropout
https://github.com/ckmarkoh/ntc_deeplearning_tensorflow/bl
ob/master/sec2/dropout.ipynb
模型儲存與載入
• 儲存模型參數
• 載入模型參數
saver = tf.train.Saver(max_to_keep=10)
saver.save(sess, "model.ckpt")
saver = tf.train.Saver()
saver.restore(sess, "model.ckpt")
講師資訊
• Email: ckmarkoh at gmail dot com
• Blog: http://cpmarkchang.logdown.com
• Github: https://github.com/ckmarkoh
Mark Chang
• Facebook: https://www.facebook.com/ckmarkoh.chang
• Slideshare: http://www.slideshare.net/ckmarkohchang
• Linkedin: https://www.linkedin.com/pub/mark-
chang/85/25b/847
66

More Related Content

What's hot

What's hot (20)

強化學習 Reinforcement Learning
強化學習 Reinforcement Learning強化學習 Reinforcement Learning
強化學習 Reinforcement Learning
 
[系列活動] 手把手打開Python資料分析大門
[系列活動] 手把手打開Python資料分析大門[系列活動] 手把手打開Python資料分析大門
[系列活動] 手把手打開Python資料分析大門
 
Unity遊戲程式設計 - 3D物件與光源設定
Unity遊戲程式設計 - 3D物件與光源設定 Unity遊戲程式設計 - 3D物件與光源設定
Unity遊戲程式設計 - 3D物件與光源設定
 
Num py basic(2) - v01
Num py   basic(2) - v01Num py   basic(2) - v01
Num py basic(2) - v01
 
Unity遊戲程式設計 - 2D運動與碰撞處理I
Unity遊戲程式設計 - 2D運動與碰撞處理IUnity遊戲程式設計 - 2D運動與碰撞處理I
Unity遊戲程式設計 - 2D運動與碰撞處理I
 
Ch5 範例
Ch5 範例Ch5 範例
Ch5 範例
 
Ch11 範例
Ch11 範例Ch11 範例
Ch11 範例
 
Ppt 26-50
Ppt 26-50Ppt 26-50
Ppt 26-50
 
Ch2 教學
Ch2 教學Ch2 教學
Ch2 教學
 
Num py basic(1) - v01
Num py   basic(1) - v01Num py   basic(1) - v01
Num py basic(1) - v01
 
Ch12
Ch12Ch12
Ch12
 
Unity遊戲程式設計(09) 3D物件與光源設定
Unity遊戲程式設計(09) 3D物件與光源設定Unity遊戲程式設計(09) 3D物件與光源設定
Unity遊戲程式設計(09) 3D物件與光源設定
 
Ppt 1-50
Ppt 1-50Ppt 1-50
Ppt 1-50
 
Sym py edu
Sym py eduSym py edu
Sym py edu
 
Ppt 136-136
Ppt 136-136Ppt 136-136
Ppt 136-136
 
20161209-Julia Taiwan first meetup-julia語言入門
20161209-Julia Taiwan first meetup-julia語言入門20161209-Julia Taiwan first meetup-julia語言入門
20161209-Julia Taiwan first meetup-julia語言入門
 
Ppt 51-77
Ppt 51-77Ppt 51-77
Ppt 51-77
 
Solitaire with Greenfoot #2
Solitaire with Greenfoot #2Solitaire with Greenfoot #2
Solitaire with Greenfoot #2
 
Ch12 範例
Ch12 範例Ch12 範例
Ch12 範例
 
R intro 20140716-basic
R intro 20140716-basicR intro 20140716-basic
R intro 20140716-basic
 

Similar to TensorFlow 深度學習快速上手班--深度學習

Computer vision introduction
Computer vision introductionComputer vision introduction
Computer vision introductionFEG
 
Pytorch cnn netowork introduction 20240318
Pytorch cnn netowork introduction 20240318Pytorch cnn netowork introduction 20240318
Pytorch cnn netowork introduction 20240318FEG
 
Behavior+tree+ai lite
Behavior+tree+ai liteBehavior+tree+ai lite
Behavior+tree+ai lite勇浩 赖
 
Refactoring with Patterns in PHP
Refactoring with Patterns in PHPRefactoring with Patterns in PHP
Refactoring with Patterns in PHPJace Ju
 
用 Keras 玩 Machine Learning
用 Keras 玩 Machine Learning用 Keras 玩 Machine Learning
用 Keras 玩 Machine Learning家弘 周
 
人工智慧09_神經網路(TensorFlow+Keras)
人工智慧09_神經網路(TensorFlow+Keras)人工智慧09_神經網路(TensorFlow+Keras)
人工智慧09_神經網路(TensorFlow+Keras)Fuzhou University
 
學院碩士班_非監督式學習_使用Orange3直接使用_分群_20240417.pdf
學院碩士班_非監督式學習_使用Orange3直接使用_分群_20240417.pdf學院碩士班_非監督式學習_使用Orange3直接使用_分群_20240417.pdf
學院碩士班_非監督式學習_使用Orange3直接使用_分群_20240417.pdfFEG
 
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生Jason Tsai
 
Hello DNN
Hello DNNHello DNN
Hello DNNevan li
 
2023 Decision Tree analysis in business practices
2023 Decision Tree analysis in business practices2023 Decision Tree analysis in business practices
2023 Decision Tree analysis in business practicesFEG
 
[students AI workshop] Pytorch
[students AI workshop]  Pytorch[students AI workshop]  Pytorch
[students AI workshop] PytorchTzu-Wei Huang
 
PHPUnit slide formal
PHPUnit slide formalPHPUnit slide formal
PHPUnit slide formaljameslabs
 
建造与理解-用Python实现深度学习框架
建造与理解-用Python实现深度学习框架建造与理解-用Python实现深度学习框架
建造与理解-用Python实现深度学习框架ZhenChen57
 
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生Jason Tsai
 
文學通的開發心路歷程
文學通的開發心路歷程文學通的開發心路歷程
文學通的開發心路歷程建銘 廖
 
Java SE 7 技術手冊投影片第 11 章 - 執行緒與並行API
Java SE 7 技術手冊投影片第 11 章 - 執行緒與並行APIJava SE 7 技術手冊投影片第 11 章 - 執行緒與並行API
Java SE 7 技術手冊投影片第 11 章 - 執行緒與並行APIJustin Lin
 

Similar to TensorFlow 深度學習快速上手班--深度學習 (20)

LabView with Lego NXT
LabView  with Lego NXTLabView  with Lego NXT
LabView with Lego NXT
 
Computer vision introduction
Computer vision introductionComputer vision introduction
Computer vision introduction
 
Pytorch cnn netowork introduction 20240318
Pytorch cnn netowork introduction 20240318Pytorch cnn netowork introduction 20240318
Pytorch cnn netowork introduction 20240318
 
Behavior+tree+ai lite
Behavior+tree+ai liteBehavior+tree+ai lite
Behavior+tree+ai lite
 
Refactoring with Patterns in PHP
Refactoring with Patterns in PHPRefactoring with Patterns in PHP
Refactoring with Patterns in PHP
 
Tip for Editors
Tip for EditorsTip for Editors
Tip for Editors
 
用 Keras 玩 Machine Learning
用 Keras 玩 Machine Learning用 Keras 玩 Machine Learning
用 Keras 玩 Machine Learning
 
人工智慧09_神經網路(TensorFlow+Keras)
人工智慧09_神經網路(TensorFlow+Keras)人工智慧09_神經網路(TensorFlow+Keras)
人工智慧09_神經網路(TensorFlow+Keras)
 
學院碩士班_非監督式學習_使用Orange3直接使用_分群_20240417.pdf
學院碩士班_非監督式學習_使用Orange3直接使用_分群_20240417.pdf學院碩士班_非監督式學習_使用Orange3直接使用_分群_20240417.pdf
學院碩士班_非監督式學習_使用Orange3直接使用_分群_20240417.pdf
 
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
 
例外處理
例外處理例外處理
例外處理
 
Hello DNN
Hello DNNHello DNN
Hello DNN
 
2023 Decision Tree analysis in business practices
2023 Decision Tree analysis in business practices2023 Decision Tree analysis in business practices
2023 Decision Tree analysis in business practices
 
[students AI workshop] Pytorch
[students AI workshop]  Pytorch[students AI workshop]  Pytorch
[students AI workshop] Pytorch
 
PHPUnit slide formal
PHPUnit slide formalPHPUnit slide formal
PHPUnit slide formal
 
Python系列1
Python系列1Python系列1
Python系列1
 
建造与理解-用Python实现深度学习框架
建造与理解-用Python实现深度学习框架建造与理解-用Python实现深度学习框架
建造与理解-用Python实现深度学习框架
 
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
Convolutional Neural Networks (CNN) — 卷積神經網路的前世今生
 
文學通的開發心路歷程
文學通的開發心路歷程文學通的開發心路歷程
文學通的開發心路歷程
 
Java SE 7 技術手冊投影片第 11 章 - 執行緒與並行API
Java SE 7 技術手冊投影片第 11 章 - 執行緒與並行APIJava SE 7 技術手冊投影片第 11 章 - 執行緒與並行API
Java SE 7 技術手冊投影片第 11 章 - 執行緒與並行API
 

More from Mark Chang

Modeling the Dynamics of SGD by Stochastic Differential Equation
Modeling the Dynamics of SGD by Stochastic Differential EquationModeling the Dynamics of SGD by Stochastic Differential Equation
Modeling the Dynamics of SGD by Stochastic Differential EquationMark Chang
 
Modeling the Dynamics of SGD by Stochastic Differential Equation
Modeling the Dynamics of SGD by Stochastic Differential EquationModeling the Dynamics of SGD by Stochastic Differential Equation
Modeling the Dynamics of SGD by Stochastic Differential EquationMark Chang
 
Information in the Weights
Information in the WeightsInformation in the Weights
Information in the WeightsMark Chang
 
Information in the Weights
Information in the WeightsInformation in the Weights
Information in the WeightsMark Chang
 
PAC Bayesian for Deep Learning
PAC Bayesian for Deep LearningPAC Bayesian for Deep Learning
PAC Bayesian for Deep LearningMark Chang
 
PAC-Bayesian Bound for Deep Learning
PAC-Bayesian Bound for Deep LearningPAC-Bayesian Bound for Deep Learning
PAC-Bayesian Bound for Deep LearningMark Chang
 
Domain Adaptation
Domain AdaptationDomain Adaptation
Domain AdaptationMark Chang
 
NTU ML TENSORFLOW
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOWMark Chang
 
NTHU AI Reading Group: Improved Training of Wasserstein GANs
NTHU AI Reading Group: Improved Training of Wasserstein GANsNTHU AI Reading Group: Improved Training of Wasserstein GANs
NTHU AI Reading Group: Improved Training of Wasserstein GANsMark Chang
 
Generative Adversarial Networks
Generative Adversarial NetworksGenerative Adversarial Networks
Generative Adversarial NetworksMark Chang
 
Applied Deep Learning 11/03 Convolutional Neural Networks
Applied Deep Learning 11/03 Convolutional Neural NetworksApplied Deep Learning 11/03 Convolutional Neural Networks
Applied Deep Learning 11/03 Convolutional Neural NetworksMark Chang
 
The Genome Assembly Problem
The Genome Assembly ProblemThe Genome Assembly Problem
The Genome Assembly ProblemMark Chang
 
DRAW: Deep Recurrent Attentive Writer
DRAW: Deep Recurrent Attentive WriterDRAW: Deep Recurrent Attentive Writer
DRAW: Deep Recurrent Attentive WriterMark Chang
 
淺談深度學習
淺談深度學習淺談深度學習
淺談深度學習Mark Chang
 
Variational Autoencoder
Variational AutoencoderVariational Autoencoder
Variational AutoencoderMark Chang
 
TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用Mark Chang
 
TensorFlow 深度學習快速上手班--自然語言處理應用
TensorFlow 深度學習快速上手班--自然語言處理應用TensorFlow 深度學習快速上手班--自然語言處理應用
TensorFlow 深度學習快速上手班--自然語言處理應用Mark Chang
 
TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習Mark Chang
 
Computational Linguistics week 10
 Computational Linguistics week 10 Computational Linguistics week 10
Computational Linguistics week 10Mark Chang
 

More from Mark Chang (20)

Modeling the Dynamics of SGD by Stochastic Differential Equation
Modeling the Dynamics of SGD by Stochastic Differential EquationModeling the Dynamics of SGD by Stochastic Differential Equation
Modeling the Dynamics of SGD by Stochastic Differential Equation
 
Modeling the Dynamics of SGD by Stochastic Differential Equation
Modeling the Dynamics of SGD by Stochastic Differential EquationModeling the Dynamics of SGD by Stochastic Differential Equation
Modeling the Dynamics of SGD by Stochastic Differential Equation
 
Information in the Weights
Information in the WeightsInformation in the Weights
Information in the Weights
 
Information in the Weights
Information in the WeightsInformation in the Weights
Information in the Weights
 
PAC Bayesian for Deep Learning
PAC Bayesian for Deep LearningPAC Bayesian for Deep Learning
PAC Bayesian for Deep Learning
 
PAC-Bayesian Bound for Deep Learning
PAC-Bayesian Bound for Deep LearningPAC-Bayesian Bound for Deep Learning
PAC-Bayesian Bound for Deep Learning
 
Domain Adaptation
Domain AdaptationDomain Adaptation
Domain Adaptation
 
NTU ML TENSORFLOW
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOW
 
NTHU AI Reading Group: Improved Training of Wasserstein GANs
NTHU AI Reading Group: Improved Training of Wasserstein GANsNTHU AI Reading Group: Improved Training of Wasserstein GANs
NTHU AI Reading Group: Improved Training of Wasserstein GANs
 
Generative Adversarial Networks
Generative Adversarial NetworksGenerative Adversarial Networks
Generative Adversarial Networks
 
Applied Deep Learning 11/03 Convolutional Neural Networks
Applied Deep Learning 11/03 Convolutional Neural NetworksApplied Deep Learning 11/03 Convolutional Neural Networks
Applied Deep Learning 11/03 Convolutional Neural Networks
 
The Genome Assembly Problem
The Genome Assembly ProblemThe Genome Assembly Problem
The Genome Assembly Problem
 
DRAW: Deep Recurrent Attentive Writer
DRAW: Deep Recurrent Attentive WriterDRAW: Deep Recurrent Attentive Writer
DRAW: Deep Recurrent Attentive Writer
 
淺談深度學習
淺談深度學習淺談深度學習
淺談深度學習
 
Variational Autoencoder
Variational AutoencoderVariational Autoencoder
Variational Autoencoder
 
TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用
 
TensorFlow 深度學習快速上手班--自然語言處理應用
TensorFlow 深度學習快速上手班--自然語言處理應用TensorFlow 深度學習快速上手班--自然語言處理應用
TensorFlow 深度學習快速上手班--自然語言處理應用
 
TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習
 
Computational Linguistics week 10
 Computational Linguistics week 10 Computational Linguistics week 10
Computational Linguistics week 10
 
Neural Doodle
Neural DoodleNeural Doodle
Neural Doodle
 

TensorFlow 深度學習快速上手班--深度學習

Editor's Notes

  1. y = \frac{1}{ 1+e^{- ( w_{1} x_{1} + w_{2}x_{2}+w_{b} ) }} & n_{in} = w_{1} x_{1} + w_{2}x_{2}+w_{b} \\ & n_{out} = \frac{1}{1+e^{-n_{in}}}
  2. w_{1}x_{1}+w_{2}x_{2}+w_{b} = 0 w_{1}x_{1}+w_{2}x_{2}+w_{b} < 0 w_{1}x_{1}+w_{2}x_{2}+w_{b} >0
  3. y = \frac{1}{1+e^{-(20x_{1}+20x_{2}-30)}} 20x_{1}+20x_{2}-30 = 0
  4. & J = -( z_{1} log(n_{21(out)}) + (1-z_{1}) log (1 -n_{21(out)} )) \\ &\mspace{30mu} -( z_{2} log(n_{22(out)}) + (1-z_{2}) log (1 -n_{22(out)} )) \\ & n_{out} \approx 0 \text{ and } z = 0 \Rightarrow J \approx 0 \\ & n_{out} \approx 1 \text{ and } z = 1 \Rightarrow J \approx 0 \\ & n_{out} \approx 0 \text{ and } z = 1 \Rightarrow J \approx \infty \\ & n_{out} \approx 1 \text{ and } z = 0 \Rightarrow J \approx \infty \\
  5. & w_{21,11} \leftarrow w_{21,11} - \eta \dfrac{\partial J}{\partial w_{21,11}} \\ & w_{21,12} \leftarrow w_{21,12} - \eta \dfrac{\partial J}{\partial w_{21,12}} \\ & w_{21,b} \leftarrow w_{21,b} - \eta \dfrac{\partial J}{\partial w_{21,b}} \\ & w_{22,11} \leftarrow w_{21,11} - \eta \dfrac{\partial J}{\partial w_{22,11}} \\ & w_{22,12} \leftarrow w_{21,12} - \eta \dfrac{\partial J}{\partial w_{22,12}} \\ & w_{22,b} \leftarrow w_{21,b} - \eta \dfrac{\partial J}{\partial w_{22,b}} \\ &w_{11,x} \leftarrow w_{11,x} - \eta \dfrac{\partial J}{\partial w_{11,x}} \\ &w_{11,y} \leftarrow w_{11,y} - \eta \dfrac{\partial J}{\partial w_{11,y}} \\ &w_{11,b} \leftarrow w_{11,b} - \eta \dfrac{\partial J}{\partial w_{11,b}} \\ &w_{12,x} \leftarrow w_{12,x} - \eta \dfrac{\partial J}{\partial w_{12,x}} \\ &w_{12,y} \leftarrow w_{12,y} - \eta \dfrac{\partial J}{\partial w_{12,y}} \\ &w_{12,b} \leftarrow w_{12,b} - \eta \dfrac{\partial J}{\partial w_{12,b}} \\ ( – \dfrac{ \partial J}{\partial w_{0}} , – \dfrac{ \partial J}{\partial w_{1}} )
  6. \dfrac{\partial J}{\partial w_{21,11}} = \dfrac{\partial J}{\partial n_{21(out)}} \dfrac{\partial n_{21(out)}}{\partial n_{21(in)}} \dfrac{\partial n_{21(in)}}{\partial w_{21,11}} = (n_{21(out)}-z_{1}) n_{11(out)} \\ \delta_{21(out)} \delta_{21(in)} n_{11(out)} w_{21,11} \leftarrow w_{21,11} - \eta
  7. \dfrac{\partial J}{\partial w_{11,x}} = \dfrac{\partial J}{\partial n_{21(out)}} \dfrac{\partial n_{21(out)}}{\partial n_{21(in)}} \dfrac{\partial n_{21(in)}}{\partial w_{21,11}} w_{11,x} \leftarrow w_{11,x} - \eta \delta_{11(in)} x
  8. & {\color[rgb]{0.597455,0.000000,0.759310}\delta_{11(in)}} =\dfrac{\partial J}{\partial n_{11(in)}} ={\color[rgb]{1.000000,0.500000,0.000000}\dfrac{\partial J}{\partial n_{21(out)}} } \dfrac{\partial n_{21(out)}}{\partial n_{11(in)}} + {\color[rgb]{1.000000,0.500000,0.000000}\dfrac{\partial J}{\partial n_{22(out)}}} \dfrac{\partial n_{22(out)}}{\partial n_{11(in)}} \\ & {\color[rgb]{0.597455,0.000000,0.759310}\delta_{11(in)}} =\dfrac{\partial J}{\partial n_{11(in)}} ={\color[rgb]{1.000000,0.500000,0.000000}\dfrac{\partial J}{\partial n_{21(out)}} } \dfrac{\partial n_{21(out)}}{\partial n_{11(in)}} + {\color[rgb]{1.000000,0.500000,0.000000}\dfrac{\partial J}{\partial n_{22(out)}}} \dfrac{\partial n_{22(out)}}{\partial n_{11(in)}} \\ &= {\color[rgb]{1.000000,0.500000,0.000000}\dfrac{\partial J}{\partial n_{21(out)}}} {\color[rgb]{1.000000,0.000000,0.000000}\dfrac{\partial n_{21(out)}}{\partial n_{21(in)}} } {\color[rgb]{0.795165,0.000000,0.447221}\dfrac{\partial n_{21(in)}}{\partial n_{11(out)}} } {\color[rgb]{0.597455,0.000000,0.759310}\dfrac{\partial n_{11(out)}}{\partial n_{11(in)}} } + {\color[rgb]{1.000000,0.500000,0.000000}\dfrac{\partial J_{2}}{\partial n_{22(out)}} } {\color[rgb]{1.000000,0.000000,0.000000}\dfrac{\partial n_{22(out)}}{\partial n_{22(in)}} } {\color[rgb]{0.795165,0.000000,0.447221}\dfrac{\partial n_{22(in)}}{\partial n_{11(out)}} } {\color[rgb]{0.597455,0.000000,0.759310}\dfrac{\partial n_{11(out)}}{\partial n_{11(in)}}} \\ &= ({\color[rgb]{1.000000,0.500000,0.000000}\dfrac{\partial J}{\partial n_{21(out)}}} {\color[rgb]{1.000000,0.000000,0.000000}\dfrac{\partial n_{21(out)}}{\partial n_{21(in)}} } {\color[rgb]{0.795165,0.000000,0.447221}\dfrac{\partial n_{21(in)}}{\partial n_{11(out)}} } + {\color[rgb]{1.000000,0.500000,0.000000}\dfrac{\partial J_{2}}{\partial n_{22(out)}} } {\color[rgb]{1.000000,0.000000,0.000000}\dfrac{\partial n_{22(out)}}{\partial n_{22(in)}} } {\color[rgb]{0.795165,0.000000,0.447221}\dfrac{\partial n_{22(in)}}{\partial n_{11(out)}} }) {\color[rgb]{0.597455,0.000000,0.759310}\dfrac{\partial n_{11(out)}}{\partial n_{11(in)}}} \\ &= ( {\color[rgb]{1.000000,0.000000,0.000000}\delta_{21(in)} } {\color[rgb]{0.795165,0.000000,0.447221}w_{21,11} } + {\color[rgb]{1.000000,0.000000,0.000000}\delta_{22(in)} } {\color[rgb]{0.795165,0.000000,0.447221}w_{22,11} }) {\color[rgb]{0.597455,0.000000,0.759310}\dfrac{\partial n_{11(out)}}{\partial n_{11(in)}}} \\
  9. J = cross\_entropy + \lambda \sum_{i,j} w_{i,j}^{2}
  10. & x_{1}^{(2)}\\ & x_{2}^{(2)} & x_{1}^{(1)}\\ & x_{2}^{(1)} y^{(1)} y^{(2)}
  11. w \leftarrow w(1-dropout\_rate)