SlideShare a Scribd company logo
1 of 21
Download to read offline
Neural Probabilistic Language Model
神經機率語言模型與word2vec
By Mark Chang
神經機率語言模型與 word2vec
● 語意向量
● 類神經網路
● word2vec
n-gram 的缺陷
● 容易受到維度爆炸的影響。
● 只能得出表面文字的關聯,無法得出較深層的語意。
● 事實上,語意可從其附近的字詞來得知。
罷免 蔡正元 失敗
罷免 祭止兀 失敗
蔡正元 是 最佳 助選員
祭止兀 是 最佳 助選員
祭止兀和蔡正元,
語意相近
語意向量
● 把字詞對應到一個 n 維度的向量。
祭止兀 (1, 1,..., xn
)
蔡正元 (1, 1,..., xn
)
罷免 蔡正元 失敗
罷免 祭止兀 失敗
蔡正元 是 最佳 助選員
祭止兀 是 最佳 助選員
(x1
= 罷免 , x2
= 助選員 ,..., xn
)
石內卜 (0, 0,..., xn
)
語意向量
祭止兀 (x1
, x2
, ...., xn
)
蔡正元 (x1
, x2
, ...., xn
)
石內卜 (x1
, x2
, ...., xn
)
語意向量
● 語意上越相近的詞,在向量空間中的夾角越小。
祭止兀 (x1
, x2
, ...., xn
)
罷免 (x1
, x2
, ...., xn
)
蔡正元 (x1
, x2
, ...., xn
)
自己人 (x1
, x2
, ...., xn
)
帥哥 (x1
, x2
, ...., xn
)
石內卜 (x1
, x2
, ...., xn
)
割闌尾 (x1
, x2
, ...., xn
)
語意向量
● Cosine Similarity
– 向量 A 和 向量 B 的 Cosine Similarity 為:
(A·B) / ( |A| * |B| )
祭止兀 (b1
, b2
, ...., bn
)
蔡正元 (a1
, a2
, ...., an
)
a1
b1
+ a2
b2
+....+ an
bn
蔡正元與祭止兀的 Cosine Similarity 為:
a1
2
+a2
2
+....+an
2
b1
2
+b2
2
+....+bn
2
類神經網路
● 一種複雜的機器學習模型,其原理是模仿神經元的
構造。
● 神經元可從輸入訊息中做運算組合,輸出結果。
神經元與動作電位
http://humanphisiology.wikispaces
.com/file/view/neuron.png/2164608
14/neuron.png
http://upload.wikimedia.org/wikipedia/
commons/thumb/4/4a/Action_potential.sv
g/1037px-Action_potential.svg.png
w1
x1
x2
y=w1
*x1
+w2
*x2
+w3
*x3
+b
x3
w2
w3
1
b
z= 1 / ( 1+e-y
)
Sigmoid function
模仿神經元
http://upload.wikimedia.org/wikipedia/comm
ons/thumb/8/88/Logistic-curve.svg/1280px-L
ogistic-curve.svg.png
類神經網路
http://cpmarkchang.logdown.com/posts/277
349-neural-network-backward-propagation
訓練類神經網路
類神經網路
類神經網路
測試資料 輸出值
訓練資料
訓練
輸出值
修正
訓練
完成
訓練前
太陽花
香蕉
訓練中
香蕉
太陽
花
調整參數
訓練後
香蕉
太陽花
word2vec
● 一種神經機率語言模型。
● 用類神經網路訓練,得出每個字詞的語意向量。
內湖 石內卜 祭止兀 罷免 失敗
車輪黨 闌尾 祭止兀 罷免 失敗
內湖
石內卜
失敗
罷免
闌尾
失敗
祭止兀祭止兀
罷免
車輪黨
實作 3 : word2vec
●
先對語料庫進行斷詞:載入繁體字典,並加入自
定詞彙。
● 找出與自定詞彙最相近的詞。
●
任意挑選兩個詞,計算其相似程度。
延伸閱讀
● 類神經網路訓練過程,公式推導:
– http://cpmarkchang.logdown.com/posts/277349-neu
ral-network-backward-propagation
● 神經語言模型:
– http://cpmarkchang.logdown.com/posts/255785-neura
l-network-neural-probabilistic-language-model
– http://cpmarkchang.logdown.com/posts/276263--hier
archical-probabilistic-neural-networks-neural-net
work-language-model
講者聯絡方式:
Mark Chang
Github : http://github.com/ckmarkoh
Blog : http://cpmarkchang.logdown.com
email : ckmarkoh at gmail.com

More Related Content

More from Mark 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
 
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
 
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
 
TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習Mark Chang
 
Computational Linguistics week 10
 Computational Linguistics week 10 Computational Linguistics week 10
Computational Linguistics week 10Mark Chang
 
TensorFlow 深度學習講座
TensorFlow 深度學習講座TensorFlow 深度學習講座
TensorFlow 深度學習講座Mark Chang
 
Computational Linguistics week 5
Computational Linguistics  week 5Computational Linguistics  week 5
Computational Linguistics week 5Mark Chang
 
Neural Art (English Version)
Neural Art (English Version)Neural Art (English Version)
Neural Art (English Version)Mark Chang
 
AlphaGo in Depth
AlphaGo in Depth AlphaGo in Depth
AlphaGo in Depth Mark Chang
 
Image completion
Image completionImage completion
Image completionMark Chang
 

More from Mark Chang (20)

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
 
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 深度學習快速上手班--自然語言處理應用
 
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 深度學習講座
TensorFlow 深度學習講座TensorFlow 深度學習講座
TensorFlow 深度學習講座
 
Computational Linguistics week 5
Computational Linguistics  week 5Computational Linguistics  week 5
Computational Linguistics week 5
 
Neural Art (English Version)
Neural Art (English Version)Neural Art (English Version)
Neural Art (English Version)
 
AlphaGo in Depth
AlphaGo in Depth AlphaGo in Depth
AlphaGo in Depth
 
Image completion
Image completionImage completion
Image completion
 

Neural Language Model Tutorial