Professional Documents
Culture Documents
04 Draft
04 Draft
(_hx“)
Lecture 4: Theory of Generalization
Hsuan-Tien Lin (ó“0)
htlin@csie.ntu.edu.tw
Roadmap
1 When Can Machines Learn?
2 Why Can Machines Learn?
• for ✏ < 0.5, Eout (g) > ✏ if every yn = +1 satisfies xn > 2✏ ( 0,2 幻
2 3 *
✓ ◆ Eoutlg ) ⽣
2 2✏ N
⼆ > E
4
P Ein (g) Eout (g) > ✏ 5
| {z } 2
"
0
( ⼀些 )
1
若 阿 3⽇ 多 項 這 个 bound
,
也知 , 就 沒有 意 火 了 ! 在 之中 ⾃由 選擇 將 ⼤家 制 咲 ⽣
,
"
不好 事情 的 机 率 " ⽤ 联 集 拆開
" "
, ,
算 每 个 不好 事情 發⽣ 的 机 率
where did uniform bound fail
to consider for M = 1?
無法 處理 0 的 狀況 i.
要 找 出 壞事 重疊 的 部分
, 長得 差不多 的 ⼈ 歸類
T
,
X (
資料 看 出去 則 只有 年中線 2
,
•x1
。
种是圈 ,
⼀
种 是叉 、
•x1
h2
h1
•x1
•x2
4:
⇥ ⇥
7
⇥ ⇥ M
L
⼈
•x1
h3
h2
•x2 h4
h1
4:
⇥ ⇥
⇥ ⇥
若有 35 input 且 排列 呈現 三⾓形 ,
•x2 ⇥
⇥
•x3 8:
⇥
⇥ →
←
⇥
⇥
always 8 for three inputs? ⇥ 0
t
⇥
Hsuan-Tien Lin (NTU CSIE) Machine Learning 7/49
Theory of Generalization Effective Number of Lines
若 三 族 排列 在 同⼀ 直線 上 ,
⇥ ←
若有 4 5点 2
T
for four inputs x1 , x2 , x3 , x4
⇥ ⇥
⇥
•x1
•x4 ← ⇥ ⇥ n
•x2
⇥
•x3 14: 2⇥
T
※
" "
T
⇥ ⇥
for any four inputs ⇥
at most 14
⇥
⇥
t
⇥
⇣ ⌘ 4 14 < 2N
希望 ⼩ → 2 · effective(N) · exp 2✏2 N
nottoobig small
( 取代 M )
Questions?
除了 線性 以外 的 H
Dichotomies: Mini-hypotheses
H = {hypothesis h : X ! {⇥, }}
• call
h.im
,
⽤ dichotomyset ⼤⼩ 衡量 M 前
Growth Function
dichotomy 是 由 先前 選 好 的
⼼ 化 決定 可能 的 未來 理論 分析 有 ⿇煩 ,
,
i.
想 移除 的 ✗ 的 依賴 選擇 ✗ 的 各 种 可能性 取 Max 的 dicnotomy ,
lines in 2D
,
• finite, upper-bounded by 2N
Perceptron 較難
-7
Growth Function for Positive Rays
先 看 較 簡單 的
h(x) = 1 h(x) = +1
a
維實 取
...
-
x1 x2 x3 xN
bdi
00 , v
0 0 0 ) v
• X = R (one dimensional)
X X X ) X "
要有向 0
, ,
; ⼗ 1
此例 可以 切 出 多少 dichotomyi
one dichotomy for a 2 each spot (xn , xn+1 ): x1 x2 x3 x4
mH (N) = N + 1 最多 N_n 种 ,
⇥
⇥ ⇥
⇥ ⇥ ⇥
(N + 1)⌧ 2N when N large! ⇥ ⇥ ⇥ ⇥
x1 x2 x3 ... xN
• X = R (one dimensional)
• H contains h, where each h(x) = +1 iff x 2 [`, r ), 1 otherwise
• X = R2 (two dimensional)
• H contains h, wherebottom
h(x) = +1 iff x in a
bottom
what is mH (N)?
這樣 的 h 的 成長 函 邦 長 怎樣 ?
可以 ⽤ 个 多 边 形 將 所有 的 吳 速 起 向 外 擴 都是 正 截+ 都是 負
⼀
,
up
•
mH (N) = 2 +
✗
−
˙
+
不論是哪 种 dichotomy 都 可以 ⽤ 凸 多 边 形 凸 集合 ) 做出 ⼼
bottom
成長 出 取 , N 族 共有 味中 dichotomy
2
hnl 了 ) 8
⼆
mH (N) = 2N ()
exists N inputs that can be shattered linesonk
⇥ ⇤ ? ⇣ ⌘
P Ein (g) Eout (g) > ✏ 2 · mH (N) · exp 2✏2 N
但 若 想 wnvexsetiexp ⼼ 前⾯ 指 取 成長 後⾯ 指 邦 下降 不 ⼀定 能 確保 即使 N 夠 ⼤
,
, ,
,
Ein 和 Eout
for 2D or general perceptrons, 夠 接近
mH (N) polynomial?
Break Point of H
what do we know about 2D perceptrons now?
three inputs: ‘exists’ shatter;
four inputs, ‘for all’ no shatter
4
"
"
4 即 為 breakpointiiczi
Questions?
⇣ ⌘
1 2
4mH (2N) exp 8 ✏ N
if k exists ⇣ ⌘
4(2N)k 1 exp 1 2
8 ✏ N
goodilargeenough ,
幾個 條件 使 learning 可以 做到 ;
成長出 取 要 在耵 地⽅ 露出 ⼀線曙光
→
if 1 mH (N) breaks at k (good H)
夠 ⼤的 data
2 N large enough TIBAD 發⽣ 下降 (good D) ī large
=) probably generalized ‘Eout ⇡ Ein ’, and
if 3 A picks a g with small Ein
=) probably learned! 、
(good A)
(:-) good luck)
i
lucky
好 的 演算法
Hsuan-Tien Lin (NTU CSIE) Machine Learning 23/49
Theory of Generalization Definition of VC Dimension
若 露出 曙光 為 桌 ki ⼼1 2
☆ VC Dimension
則 Maxnonbreakpoint 為 Kl ⼼ 2 4
即 vcdim
the formal name of maximum non-break point dVC ⼼了 8 VCD
Definition -
gnypothesisset 的 性質
v-noshatteriBP.ch
(the most inputs H that can shatter)
=
"
Minimumk -1
"
29 不⾏
• positive intervals: mH (N) = 12 N 2 + 12 N + 1
dVC = 2 • •
• convex sets:
不 論 給 幾 9点 恰好 排 在 圓 上 時
up
mH (N) = 2N
dVC = 1
,
convexset 來 snatter
可以 ⽤
bottom
learning
training examples
D : (x1 , y1 ), · · · , (xN , yN ) X
algorithm
A
final hypothesis
g⇡f
(historical records in bank) (‘learned’ formula to be used)
hypothesis set
H ‘worst case’ guarantee
on generalization
(set of candidate formula)
Hsuan-Tien Lin (NTU CSIE) Machine Learning 26/49
Theory of Generalization Definition of VC Dimension
Probabilistic Marbles
top
top
sample
bin
bottom
i.i.d.
same nature: can estimate P[orange] if ⇠
i.i.d. i.i.d.
VC holds for x ⇠ P(x), y ⇠ P(y |x)
| {z }
i.i.d.
(x,y ) ⇠ P(x,y )
hypothesis set
H
Questions?
2D PLA Revisited
linearly separable D with xn ⇠ P and yn = f (xn )
PLA can converge P[|Ein (g) Eout (g)| > ✏] ... by dVC = 3
PLA 得知 d
T large N large
N
夠 ⼤ 時 Eout Ein
某條 線 可以 將 data 分 得 好
Ein (g) = 0 Eout (g) ⇡ Ein (g)
PLA 確保 的
Eout (g) ⇡ 0 :-)
VC Dimension of Perceptrons
• 1D perceptron (pos/neg rays): dVC = 2
• 2D perceptrons: dVC = 3
• dVC •
3: 3 㸻 可以 shatter
• •
• dVC 3: ⇥ ⇥ 41 不⾏
?
• d-D perceptrons: dVC = d +1
two steps:
• dVC d + 1
• dVC d + 1
Reference Answer: 1
dVC is the maximum that mH (N) = 2N , and
mH (N) is the most number of dichotomies of N
inputs. So if we can find 2d+1 dichotomies on
some d + 1 inputs, mH (d + 1) = 2d+1 and
hence dVC d + 1.
dVC d +1
There are some d + 1 inputs we can shatter.
•
• visually in 2D:
• •
note: X invertible! 反 矩陣 存在 且 唯⼀
Can We Shatter X?
2 3 2 3
— xT1 — 1 0 0 ... 0
6
6 — xT2 — 7 6
7 6 1 1 0 ... 0 7
7
X=6 .. 7=6 .. .. .. 7 invertible
4 . 5 4 . . . 0 5
—xTd+1 — 1 0 ... 0 1
to shatter . . .
3 2
y1
for any y = 4 ... 5, find w such that
6 7
yd+1
X invertible! 1
sign (Xw) = y (= (Xw) = y () w=X y
Reference Answer: 4
dVC is the maximum that mH (N) = 2N , and
mH (N) is the most number of dichotomies of N
inputs. So if we cannot find 2d+2 dichotomies
on any d + 2 inputs (i.e. break point),
mH (d + 2) < 2d+2 and hence dVC < d + 2.
That is, dVC d + 1.
dVC d + 1 (1/2)
A 2D Special Case
2 3 2 3
— xT1 — 1 0 0
• • 6 — xT2 — 7 6 1 1 0 7
X=6 7=6 7
• • 4 — xT3 — 5 4 1 0 1 5
—xT4 — 1 1 1
?
⇥
? cannot be ⇥ 這 种 dichotomy 無法 產⽣
wT x4 = wT x2 + wT x3 w T x1 > 0
| {z } | {z } | {z }
⇥
Questions?
9
Degrees of Freedom
9 9 9 9
10 8 10 8 10 8 10 8 10 8
11 7 11 7 11 7 11 7 11 7
12 6 12 6 12 6 12 6 12 6
13 5 13 5 13 5 13 5 13 5
14 4 14 4 14 4 14 4 14 4
15 3 15 3 15 3 15 3 15 3
16 2 16 2 16 2 16 2 16 2
17 1 17 1 17 1 17 1 17 1
18 0 18 0 18 0 18 0 18 0
10 9 8 10 9 8 10 9 8 10 9 8 10 9 8
11 7 11 7 11 7 11 7 11 7
12 6 12 6 12 6 12 6 12 6
13 5 13 5 13 5 13 5 13 5
14 4 14 4 14 4 14 4 14 4
15 3 15 3 15 3 15 3 15 3
16 2 16 2 16 2 16 2 16 2
17 1 17 1 17 1 17 1 17 1
18 0 18 0 18 0 18 0 18 0
代表 能 做 多少 dicnotomy
dVC (H): powerfulness of H
Hsuan-Tien Lin (NTU CSIE) Machine Learning 40/49
Theory of Generalization Physical Intuition of VC Dimension
M and dVC
copied from Lecture 3 :-)
1 can we make sure that Eout (g) is close enough to Ein (g)?
2 can we make Ein (g) small enough?
small M large M
1 Yes!, 壞事 發⽣ 机 会 ⼩ 1 No!, 壞事 發⽣ 机 会 变 ⼤
P[BAD] 2 · M · exp(. . .) P[BAD] 2 · M · exp(. . .)
2 No!, too few choices 選擇 少 2 Yes!, many choices
演算法 可能 無法送 到 好 的 Ein ,
Questions?
Rephrase 壞事 發⽣ 的 机 会 ⼩⼼ 好 事 發⽣ 的 机 会 ⼤
Rephrase
. . ., with probability 1 , GOOD! 差距会 被 限制 在這 之中
r ⇣ ⌘
8 4(2N)dVC
gen. error Ein (g) Eout (g) N ln
r ⇣ ⌘ r ⇣ ⌘
8 4(2N)dVC 8 4(2N)dVC
Ein (g) N ln Eout (g) Ein (g) + N ln
p
. . . : penalty for model complexity
|{z}
⌦(N, H, )
Hsuan-Tien Lin (NTU CSIE) Machine Learning 44/49
Theory of Generalization Interpreting VC Dimension
THE VC Message
with a high probability,
r ⇣ ⌘
8 4(2N)dVC
Eout (g) Ein (g) + N ln
| {z }
⌦(N,H, )
随 dni ⽽ 不
1 較 多 排列 組合 )
d⇤vc VC dimension, dvc
dVC 1 2
given specs ✏ = 0.1, = 0.1, dVC = 3, want 4(2N) exp 8✏ N
N bound
100 2.82 ⇥ 107 Data 不 夠
1,000
10,000
9.17 ⇥ 109
1.19 ⇥ 108
1
sample complexity:
need N ⇡ 10, 000dVC in theory
100,000 1.65 ⇥ 10 38
29,300 9.99 ⇥ 10 2
Looseness of VC Bound
1 0 年 1 000 0 的 差距 ivcbound 很寬鬆
h i ⇣ ⌘
PD Ein (g) Eout (g) > ✏ 4(2N)dVC exp 1 2
8✏ N
Why? 寬鬆 的 來源
pt 未知 但 都 可以 ⽤
, Hoettding 來 確保
• Hoeffding for unknown Eout any distribution, any target
→
確保 分析 時 可以 ⽤ 任何 資料
• mH (N) instead of |H(x1 , . . . , xN )| ⽽ 抓 在 ⼿中 的
‘any’ data
,
非 只有 那筆
• N dVC instead of mH (N) ⽤ 多 項式 做 上限 的 上限 的 上限 ‘any’ H of same dVC
並非 ⽤ 真正 的 成長 函 取 確保看 个 H 只要看 其 du 就 好 不⽤ 其他 系 節
⼀
,
Questions?
Summary
1 When Can Machines Learn?