SlideShare a Scribd company logo
1 of 20
Deep Learning Basic
# Domain Adaptation
Terence Huang
Abstact
• Paper
- (2014) Unsupervised Domain Adaptation by Backpropagation
• Abstract
- 改善 train, test 相似但有些差異時預測效果不好
- 使用 Domain adaptation 概念結合 Adversarial neural network 架構執行
• 可適用任何 neural network
2
train test
Outline
• Domain Adaptation
• Adversarial neural network
• Experiments
- 數字分類
- Train 時額外提供少量標記的 test set
3
Domain Adaptation
• Domain Adaptation
- 實際問題: Train set 預測模型對有些差異的 test set 預測效果不好
- 解決方式: 將取出的 train 和 test feature 做 adapted
• 對 feature 做非監督轉換
• 使用 Adversarial neural network 同時做 轉換 & 預測
4
Label (y) ML Domain (d)
有 Train Source
沒有 Test Target
What is feature extraction
Adversarial neural network
• Forward
5
features𝑓
class label 𝑦
domain label 𝑑
⋮
feature extractor 𝐺𝑓 ; 𝜃𝑓
domain classifier 𝐺 𝑑 ; 𝜃 𝑑
label predictor 𝐺 𝑦 ; 𝜃 𝑦
Need more explain
Adversarial neural network
• Backward / Backpropagation
6
class label 𝑦
domain label 𝑑
⋮
𝜕𝐿 𝑓
𝜕𝜃 𝑓
Loss 𝐿 𝑓=
𝜕𝐿 𝑦
𝜕𝜃 𝑓
− 𝜆
𝜕𝐿 𝑑
𝜕𝜃 𝑓
𝜕𝐿 𝑦
𝜕𝜃 𝑦
Loss 𝐿 𝑦
𝜕𝐿 𝑑
𝜕𝜃 𝑑
Loss 𝐿 𝑑
features𝑓
Adversarial neural network
• Backward / Backpropagation
- Adversarial
- Domain classifier 跟 label predictor feature extractor 互相對抗
- Domain classifier 會幫助 label predictor 預測效能
7
Goal 2: 各別任務 loss 越小越好Goal 1: 整體 loss 越小越好
!
!
min
𝜃 𝑦
𝜕𝐿 𝑦
𝜕𝜃 𝑦
& min
𝜃 𝑑
𝜕𝐿 𝑑
𝜕𝜃 𝑑
min
𝜃 𝑓,𝜃 𝑦,𝜃 𝑑
𝜕𝐿 𝑦
𝜕𝜃𝑓
− 𝜆
𝜕𝐿 𝑑
𝜕𝜃𝑓
Need more explain
Adversarial neural network
• Backward / Backpropagation
- 藉由控制 𝜆 來調整訓練早期的雜訊
• 𝜆 𝑝 =
2
1+exp(−𝛾⋅𝑝)
− 1, 𝜆 ∈ [0,1], 𝑝 ∈ Linear[0,1], 𝛾 = 10
- SGD, standard stochastic gradient solvers, fail
• 𝐿𝑦 和 𝐿 𝑑 方向不一
• 無法由反向傳播更新
- GRL, gradient reversal layer, success
• 引入 pseudo-function R 𝜆(𝒙), 允許在 loss 往前傳時多增加一層叫做 gradient reversal layer
設計 Forward: 𝑅 𝜆 𝒙 = 𝒙
Backward:
𝑑𝑅 𝜆
𝑑𝒙
= −𝜆𝑰
• 就可以再度使用 SGD
Goal 1: 整體 loss 越小越好
min
𝜃 𝑓,𝜃 𝑦,𝜃 𝑑
𝜕𝐿 𝑦
𝜕𝜃𝑓
− 𝜆
𝜕𝐿 𝑑
𝜕𝜃𝑓
8
Experiments - 數字分類
Source
Methode Target
Source only 下界 0.5749 0.8665 0.5919 0.74
Sa (fernando et al., 2013) 比較 0.6078 (7.9%) 0.8672 (1.3%) 0.6157 (5.9%) 0.7635 (9.1%)
Proposed approach 本篇 0.8149 (57.9%) 0.9048 (66.1%) 0.7107 (29.3%) 0.8866 (56.7%)
Train on target 上界 0.9891 0.9244 0.9951 0.9987
Brackets: much of the gap between the lower and the upper bounds was covered
9
Experiments - 數字分類
10
Experiments - Train 時額外提供少量標記的 test set
11
• Semi-supervised domain adaptation
- When one is additionally provided with a small amount of labeled target data
• GTSRB data only
• Synthetic data only
• Both
Synthetic
+
1280 筆 GTSRB (隨機, 提供標註)
Recall
• Paper
- (2014) Unsupervised Domain Adaptation by Backpropagation
• Abstract
- 改善 train, test 相似但有些差異時預測效果不好
- 使用 Domain adaptation 概念結合 Adversarial neural network 架構執行
• 可適用任何 neural network
12
train test
Other
• GAN vs. Domain Adaptation
- GAN: generative adversarial network
13
1. 把 Classify 任務
改成影像生成
2. 把 Domain Classify 任務
改成是否為生成區分
Note. 生成的影像只能走下面那條
GAN 對 DA 做什麼
Q&A
Thanks for your attention!
14
Other
• Transfer learning vs. Domain Adaptation
15
Feature extraction
• Feature extraction
16 Back
Feature
extraction
Adversarial neural network
• Forward
17
Label (y) ML Domain (d)
有 Train Source
沒有 Test Target Back
Adversarial neural network
• Backward / Backpropagation
18
Label (y) ML Domain (d)
有 Train Source
沒有 Test Target Back
Adversarial neural network
• Backward / Backpropagation
19
Label (y) ML Domain (d)
有 Train Source
沒有 Test Target
𝐿 𝑦
𝐿 𝑑
𝐿 𝑦 − 𝜆𝐿 𝑑
Back
Adversarial neural network
• Backward / Backpropagation
20
Label (y) ML Domain (d)
有 Train Source
沒有 Test Target
𝐿 𝑦 = 0
𝐿 𝑑
−𝜆𝐿 𝑑
Back
0

More Related Content

More from Terence Huang

# Can we trust ai. the dilemma of model adjustment
# Can we trust ai. the dilemma of model adjustment# Can we trust ai. the dilemma of model adjustment
# Can we trust ai. the dilemma of model adjustmentTerence Huang
 
# 手把手 Python 資料分析 I
# 手把手 Python 資料分析 I# 手把手 Python 資料分析 I
# 手把手 Python 資料分析 ITerence Huang
 
# From statistics to ai
# From statistics to ai# From statistics to ai
# From statistics to aiTerence Huang
 
Deep Learning Advance: # Capsule net
Deep Learning Advance: # Capsule netDeep Learning Advance: # Capsule net
Deep Learning Advance: # Capsule netTerence Huang
 
Deep Learning Basic: #01 start from CNN
Deep Learning Basic: #01 start from CNNDeep Learning Basic: #01 start from CNN
Deep Learning Basic: #01 start from CNNTerence Huang
 
文字分析 Python 入門
文字分析 Python 入門文字分析 Python 入門
文字分析 Python 入門Terence Huang
 
從統計到資料科學
從統計到資料科學從統計到資料科學
從統計到資料科學Terence Huang
 

More from Terence Huang (9)

# Can we trust ai. the dilemma of model adjustment
# Can we trust ai. the dilemma of model adjustment# Can we trust ai. the dilemma of model adjustment
# Can we trust ai. the dilemma of model adjustment
 
# 手把手 Python 資料分析 I
# 手把手 Python 資料分析 I# 手把手 Python 資料分析 I
# 手把手 Python 資料分析 I
 
# From statistics to ai
# From statistics to ai# From statistics to ai
# From statistics to ai
 
#02 Next RNN
#02 Next RNN#02 Next RNN
#02 Next RNN
 
Deep Learning Advance: # Capsule net
Deep Learning Advance: # Capsule netDeep Learning Advance: # Capsule net
Deep Learning Advance: # Capsule net
 
Deep Learning Basic: #01 start from CNN
Deep Learning Basic: #01 start from CNNDeep Learning Basic: #01 start from CNN
Deep Learning Basic: #01 start from CNN
 
文字分析 Python 入門
文字分析 Python 入門文字分析 Python 入門
文字分析 Python 入門
 
從統計到資料科學
從統計到資料科學從統計到資料科學
從統計到資料科學
 
SQL 語言簡介
SQL 語言簡介 SQL 語言簡介
SQL 語言簡介
 

Deep Learning Advance: #01 Domain Adaptation

  • 1. Deep Learning Basic # Domain Adaptation Terence Huang
  • 2. Abstact • Paper - (2014) Unsupervised Domain Adaptation by Backpropagation • Abstract - 改善 train, test 相似但有些差異時預測效果不好 - 使用 Domain adaptation 概念結合 Adversarial neural network 架構執行 • 可適用任何 neural network 2 train test
  • 3. Outline • Domain Adaptation • Adversarial neural network • Experiments - 數字分類 - Train 時額外提供少量標記的 test set 3
  • 4. Domain Adaptation • Domain Adaptation - 實際問題: Train set 預測模型對有些差異的 test set 預測效果不好 - 解決方式: 將取出的 train 和 test feature 做 adapted • 對 feature 做非監督轉換 • 使用 Adversarial neural network 同時做 轉換 & 預測 4 Label (y) ML Domain (d) 有 Train Source 沒有 Test Target What is feature extraction
  • 5. Adversarial neural network • Forward 5 features𝑓 class label 𝑦 domain label 𝑑 ⋮ feature extractor 𝐺𝑓 ; 𝜃𝑓 domain classifier 𝐺 𝑑 ; 𝜃 𝑑 label predictor 𝐺 𝑦 ; 𝜃 𝑦 Need more explain
  • 6. Adversarial neural network • Backward / Backpropagation 6 class label 𝑦 domain label 𝑑 ⋮ 𝜕𝐿 𝑓 𝜕𝜃 𝑓 Loss 𝐿 𝑓= 𝜕𝐿 𝑦 𝜕𝜃 𝑓 − 𝜆 𝜕𝐿 𝑑 𝜕𝜃 𝑓 𝜕𝐿 𝑦 𝜕𝜃 𝑦 Loss 𝐿 𝑦 𝜕𝐿 𝑑 𝜕𝜃 𝑑 Loss 𝐿 𝑑 features𝑓
  • 7. Adversarial neural network • Backward / Backpropagation - Adversarial - Domain classifier 跟 label predictor feature extractor 互相對抗 - Domain classifier 會幫助 label predictor 預測效能 7 Goal 2: 各別任務 loss 越小越好Goal 1: 整體 loss 越小越好 ! ! min 𝜃 𝑦 𝜕𝐿 𝑦 𝜕𝜃 𝑦 & min 𝜃 𝑑 𝜕𝐿 𝑑 𝜕𝜃 𝑑 min 𝜃 𝑓,𝜃 𝑦,𝜃 𝑑 𝜕𝐿 𝑦 𝜕𝜃𝑓 − 𝜆 𝜕𝐿 𝑑 𝜕𝜃𝑓 Need more explain
  • 8. Adversarial neural network • Backward / Backpropagation - 藉由控制 𝜆 來調整訓練早期的雜訊 • 𝜆 𝑝 = 2 1+exp(−𝛾⋅𝑝) − 1, 𝜆 ∈ [0,1], 𝑝 ∈ Linear[0,1], 𝛾 = 10 - SGD, standard stochastic gradient solvers, fail • 𝐿𝑦 和 𝐿 𝑑 方向不一 • 無法由反向傳播更新 - GRL, gradient reversal layer, success • 引入 pseudo-function R 𝜆(𝒙), 允許在 loss 往前傳時多增加一層叫做 gradient reversal layer 設計 Forward: 𝑅 𝜆 𝒙 = 𝒙 Backward: 𝑑𝑅 𝜆 𝑑𝒙 = −𝜆𝑰 • 就可以再度使用 SGD Goal 1: 整體 loss 越小越好 min 𝜃 𝑓,𝜃 𝑦,𝜃 𝑑 𝜕𝐿 𝑦 𝜕𝜃𝑓 − 𝜆 𝜕𝐿 𝑑 𝜕𝜃𝑓 8
  • 9. Experiments - 數字分類 Source Methode Target Source only 下界 0.5749 0.8665 0.5919 0.74 Sa (fernando et al., 2013) 比較 0.6078 (7.9%) 0.8672 (1.3%) 0.6157 (5.9%) 0.7635 (9.1%) Proposed approach 本篇 0.8149 (57.9%) 0.9048 (66.1%) 0.7107 (29.3%) 0.8866 (56.7%) Train on target 上界 0.9891 0.9244 0.9951 0.9987 Brackets: much of the gap between the lower and the upper bounds was covered 9
  • 11. Experiments - Train 時額外提供少量標記的 test set 11 • Semi-supervised domain adaptation - When one is additionally provided with a small amount of labeled target data • GTSRB data only • Synthetic data only • Both Synthetic + 1280 筆 GTSRB (隨機, 提供標註)
  • 12. Recall • Paper - (2014) Unsupervised Domain Adaptation by Backpropagation • Abstract - 改善 train, test 相似但有些差異時預測效果不好 - 使用 Domain adaptation 概念結合 Adversarial neural network 架構執行 • 可適用任何 neural network 12 train test
  • 13. Other • GAN vs. Domain Adaptation - GAN: generative adversarial network 13 1. 把 Classify 任務 改成影像生成 2. 把 Domain Classify 任務 改成是否為生成區分 Note. 生成的影像只能走下面那條 GAN 對 DA 做什麼
  • 14. Q&A Thanks for your attention! 14
  • 15. Other • Transfer learning vs. Domain Adaptation 15
  • 16. Feature extraction • Feature extraction 16 Back Feature extraction
  • 17. Adversarial neural network • Forward 17 Label (y) ML Domain (d) 有 Train Source 沒有 Test Target Back
  • 18. Adversarial neural network • Backward / Backpropagation 18 Label (y) ML Domain (d) 有 Train Source 沒有 Test Target Back
  • 19. Adversarial neural network • Backward / Backpropagation 19 Label (y) ML Domain (d) 有 Train Source 沒有 Test Target 𝐿 𝑦 𝐿 𝑑 𝐿 𝑦 − 𝜆𝐿 𝑑 Back
  • 20. Adversarial neural network • Backward / Backpropagation 20 Label (y) ML Domain (d) 有 Train Source 沒有 Test Target 𝐿 𝑦 = 0 𝐿 𝑑 −𝜆𝐿 𝑑 Back 0