10. 最適化による学習
• 訓練 {(xi, yi)} (i=1…N)を匏用し、分類器を
特徴付けるパラメータwを学習
n
w = arg min ∑ l ( xi , yi ; w ) + R (w )
*
i =1
w
正則化項:
損失関数:どれだけ訓練 を
正しく分類できているか? wの好ましさ
max(0,1 − yw T x) hinge-loss (SVM)
l ( x, y; w ) = − log(1 + exp(− yw T x)) log-loss (MaxEnt)
exp(− yw T x) exp-loss (Ada Boosting)
11. 凸最適化問題
n
F (w ) = ∑ l ( xi , yi ; w ) + R(w )
i =1
• F(w)を最小にするようなwを求める
– l(x,y,w), R(w)がともに凸関数ならFも凸関数
• 従来手法(バッチ学習)
が大きす てできない
– Newton法はHessian
– 共役勾配法、L-BFGS法
– 各損失関数に特殊化された最適化法
SMO(SVM), Exponentiated GD (MaxEnt)
18. Averaged Perceptron
の効厾的な実装
入 : {(xi, yi)} yi∈{-1,1} (i=1…N) 赤字がPerceptron厭 点
w = {0,0,….0} // 初期化
wa = {0,0,….0}
loop
// 訓練データをランダムにとってくる
i [1,…,n]
s := yiwTφ(xi) // wTφ(xi)=現在の予測
// 現在の予測が外れた
if (s < 0)
w := w + yiφ(xi)
wa := wa + t yiφ(xi)
endif
t := t + 1
end
この結果は、すべてのステップ
w := w – wa/t
で平均をとったものと同じ
20. Structured Perceptron
[Collins 02]
入 : {(xi, yi)} (i = 1…N) yi∈{+1,-1}
w = {0,0,….0} // 初期化
loop
// 訓練データをランダムにとってくる
i [1,…,N]
y*=arg maxywTφ(xi,y) // 現在の予測
// 現在の予測が外れた
if (y* ≠ yi)
w := w + φ(xi, yi) – φ(xi, y*) // 正解を強くして、
勘正解を弱くする
endif
end
21. Passive Aggressive Algorithm
[Crammer, JMLR 06]
1 2
w i +1 = arg min w − w i
2
w
l ( xi , yi ; w ) = 0 l ( xi , yi ; w ) = max(1 − yi w T φ ( xi ),
0)
s.t.
• 各訓練 に対し上の問題を順に解く
1. 今の訓練 は正しく分類でき
2. これまでの重みベクトルに一番近い
• この問題は次の閉じた解を持つ
l ( xi , yi ; w )
τt =
w t +1 = w t + τ t ytφ ( xi ) 2
φ ( xi )
22. Passive Aggressive Algorithm (続)
[Crammer, JMLR 06]
• SVMと同様に制約を緩めたバージョン
1
w i +1 = arg min w − w i + Cξ s.t. l ( xi , yi ; w ) ≤ ξ ξ ≥0
2
(PA-I)
2
w
1
w i +1 = arg min w − w i + Cξ 2 s.t. l ( xi , yi ; w ) ≤ ξ
2
(PA-II)
2
w
• これらも閉じた解を持つ
w t +1 = w t + τ t ytφ ( xi )
l ( x , y ; w) l ( xi , yi ; w )
τt =
τ t = min C , i i 2 (PA-I) 1 (PA-II)
φ ( xi )
2
φ ( xi ) +
2C
23. Confidence Weighted Learning
[Dredze+ 08] [Crammer+ 08]
• 各重みについて卾勼 を入
• 直厤: 回数が少ないやつは多いやつより大きく
した方がいいだろう
• 重みベクトルは平均μ∈Rm、共分散
∑∈Rm×mのガウス分布で保持する
– μをそのまま使ってμTφ(xi)で分類
– ∑の対 成分は卾勼
(µ i +1 , Σi +1 ) = arg min DKL (Ν (µ, Σ) || Ν (µ i , Σi ) )
µ ,Σ
w~ (µ, Σ) Pr ( yi w φ ( xi ) ≥ 0 ) ≥ η
T
s.t.
32. L1正則化
n
F (w ) = ∑ l ( xi , yi ; w ) + w 1
i =1
w 1 = ∑ | wi |
• 重みの 対値の匄をペナルティに匏用
i
– Lasso正則化とも呼ばれる
– c.f. L2 正則化|w|2= ∑i wi2
• これは凸関数
– wi =0 で微分勘可能
– ちなみにL0の場合の最適化はNP完全問題
43. FOLOSまとめ
問題:f(w)+r(w)を最小化
•
w = {0,0,…,0}
•
t=1
•
loop
•
// 卾厾的勾配 法でもよい
– w = w – μ∂F(w)
– λ = λ0/(1+t)
– for each i
• wi := sign(wi) max(|wi|-λ, 0) // r(w)=|w|1
// r(w)=|w|22
wi / (1+λ)
– end for
– t := t + 1
• end loop
52. 線形 厌器の学習
(多クラス)ロジスティック回帰
( )
1
exp w φ ( x, y )
p( y | x; w ) = T
Z ( x)
( )
Z ( x) = ∑ exp w φ ( x, y ' )
T
y'
• 素性ベクトルは入 から決定される素性ベク
トルをラベル種類数分並べたもの
• 推定は argmaxy p(y|x; w) = argmaxy wTφ(x, y)
最大エントロピーモデルや線形対数モデルと同じ
52
53. L1正則化付き最尤推定 (L1-LR)による
学習
w = arg max ∑ log p( yi | xi ; w ) − C | w |1
*
w i
• 訓練データ (xi, yi) (i=1…N)を用いてwをL1正則化
付で最尤推定
• L1正則化による学習では多くの重みが0である疎
な結果が得られる
53
58. 入 abracadabra$に対する接尾辞木
接尾辞木
i 出現位置 接尾辞
12 1 12 $
11 $ 2 11 a$
$ bra 8
3 8 abra$
$
c
c 1
4 1 abracadabra$
4
a d 5 4 acadabra$
6
6 6 adabra$
bra
$
7 9 bra$
9
c
8 2 bracadabra$
c 2
d 5 9 5 cadabra$
10 7 dabra$
7
ra
$
11 10 ra$
10
12 3 racadabra$
c 58
3
59. 接尾辞木
abra abr ab bra br ra b r
の出現位置は全て同じ(8,1)
12
T=abracadabra$
11 $
$ bra 8
0 T=abracadabra$
$ 1 c
c 1
T=abracadabra$
4
a
T=abracadabra$
d
6
T=abracadabra$
bra
4
$
T=abracadabra$
9
c
2
2
c
≠
d 5
T=abracadabra$
(11,1,8,4,6)
7
ra
接尾辞木の同一枝中の
$
10
部分文字列の出現位置
3
は同じ
c 59
3
62. 各suffixの直前の文字
T=abracadabra$
Suffix Tree
i SA L B suffix
12
1 12 0 a$
11
2 11 1 r a$ $
$ bra 8
0
3 84 d abra$ $ 1 c
c 1
4 1 1 $ abracadabra$
4
a
5 4 1 r acadabra$ d
前の文字が なるの
でabraはMS
で は 6
6 6 0 c adabra$ 4 bra
$
9
7 9 3 a bra$ c
2
2
c
8 2 0 a bracadabra$
d 5
9 5 0 a cadabra$
前の文字が全て同じなの
7
でbraはMSではない ra
10 7 0 a dabra$
$
10
11 10 2 b ra$
3
12 3 0 b racadabra$ c 62
3
69. 出典
[Brants+, EMNLP 07] “Large Language Models in Machine Translation”,
•
Thorsten Brants, Ashok C. Popat, Peng Xu, Franz J. Och, Jeffrey Dean,
EMNLP 2007 http://acl.ldc.upenn.edu/D/D07/D07-1090.pdf
[Suzuki+. ACL 08] quot;Semi-Supervised Sequential Labeling and Segmentation
•
using Giga-word Scale Unlabeled Dataquot;, Jun Suzuki, Hideki Isozaki, ACL-HLT
08 http://aclweb.org/anthology-new/P/P08/P08-1076.pdf
[柴田 NLP09] ” 大規模ウ ブコーパスを用いた分布類似 計算”, 柴田
•
知秀, 夫, NLP 2009
[S. S.-Shwartz 07] “Online Learning: Theory, Algorithms, and Applications”,
•
Shai Shalev-Shwartz, The Hebrew University of Jerusalem Ph. D thesis
http://ttic.uchicago.edu/~shai/papers/ShalevThesis07.pdf
[Rosenblatt Phy. Rev. 57] The Perceptron: A Probabilistic Model for
•
Information Storage and Organization in the Brain, Cornell Aeronautical
Laboratory, Psychological Review, v65, No. 6, pp. 386-408.
70. [Freund+ 99], “Large margin classification using the perceptron algorithm” Y.
•
Freund and R. E. Schapire, 99, In Machine Learning 37(3):277-296, 1999.
[Collins 02] “Discriminative Training Methods for Hidden Markov Models: Theory and
•
Experiments with Perceptron Algorithms. EMNLP 2002,
http://www.cs.cornell.edu/Courses/cs778/2006fa/lectures/04-PerceptronHMM.pdf
[Crammer, JMLR 06] “Online Passive-Aggressive Algorithms”, Koby Crammer, Ofer
•
Dekel, Joseph Keshet, Shai Shalev-Shwartz, Yoram Singer, Journal of Machine
Learning, 2006
[Dredze+ 08] “Confidence-Weighted Linear Classification”, Mark Dredze, Koby
•
Crammer and Fernando Pereira , ICML 2008
[Crammer+ 08] “Exact Convex Confidence-Weighted Learning”, Koby Crammer,
•
Mark Dredze and Fernando Pereira, NIPS 2008
[Duchi + 08] “Efficient Projections onto the L1-Ball for Learning in High Dimensions,”
•
John Duchi, Shai Shalev-Shwartz, Yoram Singer, and Tushar Chandra, International
Conference on Machine Learning (ICML 2008)
[Gao+ 07] “A comparative study of parameter estimation methods for
•
statistical natural language processing”, ACL 2007
[Duchi+ 09] “Online and Batch Learning using Forward Looking Subgradients “,
•
John Duchi¤ Yoram Singer
71. • [Kazama+ EMNLP 03] “Evaluation and Extension of Maximum Entropy
Models with Inequality Constraints”, Jun'ichi Kazama and Jun'ichi Tsujii
EMNLP 2003
• [Andrew+ 07] Galen Andrew, Jianfeng Gao, Scalable Training of L1-
Regularized Log-Linear Models, in International Conference on Machine
Learning, 2007
• [Gao+ 07] “A Comparative Study of Parameter Estimation Methods for
Statistical Natural Language Processing “, Jianfeng Gao, Galen Andrew,
Mark Johnson, Kristina Toutanova, ACL 2007
• [Sha+ 07] “Multiplicative updates for L1- regularized linear and logistic
regression”, Fei Sha, Yonghahk Park, and Lawrence Saul, IDA 2007
• [Koh+ 07] An Interior-Point Method for Large-Scale l1-Regularized
Logistic Regression, K. Koh, S.-J. Kim, and S. Boyd JMLR 2007
• [Kudo+ 03] “Fast Methods for Kernel-based Text Analysis, aku Kudo,
Yuji Matsumoto, ACL 2003
• [Okanohara+ SDM 09] “Text Categorization with All Substring
Features”,SDM 2009, Daisuke Okanohara, Jun’ichi Tsujii