Machine Learning
Machine Learning
Lecture 1 Introduction
iii
Geometry [Link]
sum
ofabsolute errors L iF Iwxitbyil
The line that minimizes the error would be
argmini
0,5
wb
Optimization Solve
恐占Élwxitbyīl
⾼L Ě 2 [Link]Ěxit Nb⼀点yi o
b i Ěyi [Link] xiij [Link]
Rewrite Loss function
L ⼆点 lwlxi [Link] __j 12
录L Ěilwlxi xl lyi [Link] xjzzlwlxi xllxi i lxi [Link] 0
w Ě lxi [Link]
無 xi [Link]
Theability to predict is Called Generation
Probability X Ee
[Link]
When it is discrete and finite it is possible to enumerate all elements
of a subse
Distributions For we can implement a probabilitymeasure D with anotherfunction p
any X En by
letting
Rx ⼆意 PM
Thefunction p [Link] a probability mass function or discrete probability dis
tribat
Dp ⼝ R
Ofpcw El
forany w En
Ewanplw 7
Example n 1,2,3,4.5.61
⼼ 以 吸 ⼤⼝
Tina
⼀
的
It's valid type_correct to write Pc917 or Pc 1.4
Pin PcIi 213,4,5,671 ⼆7
i
Pill 21 pc i p 2 ⼆⾔
11is an event I is not
P and p are different
Gaussian
[Link] T exp⼈⾔ [Link]
i ______________
iiiiiii
CDF
it PDF
3agesRule pcylxn
yp [Link]
管哥 x
器
台 ⼆
器
是吕
gg
x and
independence
y
are independent
if
[Link] [Link] forany xerox and yEm
of
Bythe definition conditional probability⼝
⼆
pcylx 兴
名 ⼆
器
管 Ply
x and
y are independent
if given x does not changetheprobabilityof y
independent [Link]
and E Exty E x if xand y are independent
E y
[Link] Ex pnnIEy pyIXtyII [Link] Ey
pyiyI EU
xpectation
fetplxsd nction
1tfxtfxi lTaylor
nt_generating
[Link] E E E
1 吉E区 [Link]区2
Milo EIXI M x co E区2
If Mx 七 Myct then x and yhasthe same probability distribution
MGFofaGaussian Suppose x [Link]
Mxct E t 18⽐ ⾼ expl Eilx
tild f
expl fx2 [Link] dx
赢 ⼀些 tn
鉴蕊
it sumsto1after integration
亗竺
瑬紧
canpullit out ofthe integration
iexpl EW
littuii [Link]
Linear Suppose xi [Link] and X Nwnoi [Link]
tanx ombinatio
Gung ⼆ [Link]
[Link] et _Mxnuzfttii
Max taxztast [Link] Max It Max ⽐ ˊ_ˋMan
xnlt [Link]
it Mxdat Mxnlant
[Link]
lamtaunt ee
aunttitlaiiiaziintaio
anxu [Link] aunt un [Link]
ain't hit ta a
[Link] on _tai jnixi Youtube⼤学
爱丁堡⼤学
E IE tax2
E etaxI.EEetax2
⼆[Link] etauniio
etlaun aun iiaioi aiai
Wehave a [Link] [Link] [Link]
dependence and [Link] _xn arecalledindependentandidenticallydistributed [Link] samples if [Link] ⼀ 加 are mutua
dnticauydistributed independent andare drawnfromthe same distribution
知⼼
武
The discreteprobabilitydistribution of a random variablewhichtakes the value
Distribution with the probability p and the value 0 with theprobability ftp
Suppose we have a single trial
failure
Pcsuccess ⼆ P
Mhmzp
variance a
Mip pup
Likelihood
Trying to findthe optimalvalueforthe mean or standard deviationfor a distribution
of
bunch observed measurements
given a
Maximum
If we flip a coin 500times and get300heads estimate theprobabilityofgettingheads
icon Assume [Link] Bernoullirandom variables x xn with probabilityB to behands
The likelihoodof Bis
PIX 加 ㄨ了 [Link] Ǚ Pi ⼆点 fill B 1 Xī
Themaximumlikelihood estimator of B is thevaluethat maximizesthe likelihood
L Lgplx ⻘ xilogptlixiilogll
xn ⼆
singing u
pi argmaxpxiu
[Link] tu [Link]'tchangethevalueof
不⼏ o argmax
岩⼆点 给 ⼀ 晋 ⼆点 I
奭 藏
然
Lecture 3 Linear Regression
Ěǐiiin
nanny
_on points
origin
Given S
[Link] [Link] fndw such that the mean_squareerror MSL
Givendatapointswant
The act
[Link]
is called
ǚiǖǖi
offinding w training
Substituting
big 咬⼀ in L then
ㄥ ⽆惑⼼
xitgniyi 2
惑
⼆⻰ ⼼必⼀万
lying
win
⼆⻰感 vector T Ti
Thus
点
takederivativewithrespect 憥
试点
to avector
úxijxi
iiiiīiī
⼀点 i'ㄨ i
y
⼆ Ělxxw Xy
WE
INT'Xy
we Steps [Link] _minusmean is actuallycatering [Link] now has meanzero
x_x 不 不I
gifynrg
Centering
write cxyyi
f ⼼toCan
pack datapoints
just the way
òmputing the
MoorePenrose
⼼
ˊ_
化
big_ni
Sending
Features
yznixtb i b Y i Y w'Tx ⼆ ⼼中⼼
Fitting [Link] to appending 7 to x andfitting fx not
The1 canbe seen as a featureindependent the input
of
Suppose we have a datapoint x IxIn 2 3 IT
The data pointafter appending 7 becomes
IT 听 2 x 3 IT
Thedatapoint after appending1 and quadratic terms becomes
2
中化 T Xc 2 3 1 2 X2 x 3 3 九四⻛2 2x 3
Thefunction
fixing x is a polynomial linearin no not features or data
Instead
ofX⼆区 n_n XNI we have 0 [Link]
Theoptimal solution
for linear regression becomes w 10017
的
Alinear regression model is linear in the parameters w not features
A linear regression model can fit an arbitrary nonlinear function
What are the'right'features
Whatdoes it mean forthe program Glx
w we write withdata to be correct
The of w is
likelihood
log
gipgīlxi log惑病expl iyi [Link]
doesnt changeargmaxw
yi [Link]
器
⼆
点点
䉀等 痴七⼗MSE likelihood
maximizew meansminimize
maximize w
ingmatrixcalculus Lilltwy吃
Wecanexpandthe [Link] error as
L 11妔 ylliiloiw [Link] ⼆⼼中yTkloiw
yTwtgi
ing optimal solution 我⼼ y iidoiw
[Link] uioly
4⽇ wofwD [Link]
lfIEItIff
业
manorial
WE1997年g
Binary 扣 可 if with so
Classification 个 if uixtbzoisgnlnixtb
Theplane nixtb 0 Separates the two classes
Thefunction f labels one class as o and the otherclass as 7
Theclass is called binary classification becausethere are two classes
Think
gasathe prediction andgas the label
We suffer lossof 7 if we predict the label wrong
In the binary case long y ⼆卫
然⼀ same sign or different signs
Probabilistic
Making predictions based on signs
2preach
fxnflifuixtbc [Link] ⼆
SgaCwTtb
Defining probabilities ofit1
classes
ltTxtb pcg
X ⼆
ply
llxi 7 [Link] 11 ㄨ
igmoid
Function ⽔S ⼆
When s
命
[Link] 1
When ss [Link] so
probabilistic
ply ⼆411x in luixtb ⼆ 1 ⽐ ⼀ 如
approach When uixtb [Link] ya 11x 1
When uixtb s [Link] y 11x
f
Pifnixtbc [Link] ⼆Sgnlwixtb
ply it1 1X ⼆
ltexp ixtb
ply
Divideby
[Link] ⼆
毕筠华 1
fnixtbjtl
Plylxk [Link] her 1 or 1
Iynixtbk hgh
[Link]
Notation Thelogloss notation log can be misleading
ply x
he Is y the ground truth or is it a free variable ofthedata
Variablesareboundto one
What it really means is logplg [Link] points
Or 6gplgzyīlxī given a pair lxī yi in a dataset
fix if ⼼ 1 0
f
Features
pcylxiltexpl pcylxliltexpl
wo [Link]
example
inmyn dominator
[Link] nniiii
lassífcaniji
嘉华器 Y1
⼆ 灬 in this case_
中灬
嚣
Ǘniiiim㡭
[Link]
ending theclass yEY gEY
youhighestfix ⼆⽉ .es
twi
yc
rob
ability if wigs wI 中化 on
constant
inna
[Link]年化 o
iflww n ⼀⼼
f 1 if 中仪 20
1y
1
if nicola co
f ⼼如 ⻅
LogLossin thebinarycase
[Link] 州
Logloss in the multiclass cass
[Link]
binary Classification multiclass Classification
1 ifWElxko
fix 1 1 īfwhx [Link]
yE Mii Pcg1x
ficx
纸 以 管
三 器⼼ Gives
[Link] 䊺
probabiligdntributo zpl. s
1 23 ㄒ 0109 0.24 0.67IT
ofmmax
soft ax 100200300 i 1087 ftp IT
Sfmax always returns a probability distribution
When the dynamic
becomes sharp
the
range of is large the result
input ofsoftman
values are veryclose to one or Zero
That means
the max
三点 器ie 0 when T 0
forany aj that is not
We have
噐器灬
⼆
explaitmexp [Link]
TlJ
o because whenT
am is the largest and [Link] co
Lecture 6 Information Theory
How to define the amount of Information
Let IN denote the amount of informationfor event x
Desired
property Icx
of
Monotonically decreasing function of probability
If plx T
Icx
x
log前 10gzpcx
Lowprobability events need more bits whilehighprobability events need
fewer bits
login bits are equivalent to hogpix nats
Entropy The entropy of a distribution
p is defined as
Hcp H1 ㄨ ⼆ Ex
[Link] or iiii
pcxiElogpcxi
Note that of iij
Hex is not a function x
Theentropy can be interpreted as the expected number of nats needed to
ff uncertainty fi
The conditional entropy
Hcxly
of
⼆
x given y is
Exy [Link]
If x and
y are independent
[Link] logpix I
⼆
⼆ Hlx
1 EP以 ⾔Ply o
Mutual Since Hcxlg EH cxl the extra information Hcx Hcxly we know
Informationabout x given y is called the mutual information
I [Link] Hcx ⼀
Hcxly Hey H 的1
⼆
Ex yopix y I log咒
器
Cross Recall that the entropy Ex [Link] can be interpreted as drawing
Entropy message x from pix and sending it with logpix nats
This assumes that we know p What happens if we do not
We estimate p with some other distribution q
The expected numberof nats under p ofencoding messages with
distribution q is the cross entropy
Hip q Ex
pcxsElogqcx. denote
N joint
Bi the notation p qisalso used to entropy [Link]
Weneed more
than the true
nats
if we encode messages with a
distribution
distribution qother
p
Hcp E Hp q
The proof uses the inequality log t Et l again
Exnpcx I log幾
Exnpcx 1 幾
1 引 ⼼ 死 ⼆0
allback_LeiblerTheextra nats of encoding with the wrong distribution is the Kullback Leibler
divergence divergence
Thelogloss is
6g pljx 味中化 log 新[Link]
ixil wherey
is the label
Given a datapoint
[Link] wecan represent the ground truth as a distribution
ply 正guy onehotdistribution if for
Thecross entropy between the ground truth and the learned distribution is
Eynpy Eloglglx 新 pyI
logpylx.
新⻢ logPly
E
⼼
__y
logphil x
Hence the
logloss is also known as thecrossentropy loss
Lecture 7 Optimization1
Convex Ln
Optimization
录 Tw
ii
Suppose
f Rds R
The goal is SOhe
ninfa
Note min fi E fyi for any y
We want to find 姅 such that fix myfix
The point 对 is called the optimal solution or the minimize of f
There might not be a minimizer or there mighthave many
convexfunctions A function
f is convex
if
fcaxtcl [Link] x
fcy
for every x and 0East
y
⼈ For f Rs R
if器 ofis on
For
TD visualization fRd [Link] ㄨ ⼆Hix is amatrix
If His
semidefinite
c f is convex
i 以1v30foreveryvector
[Link]. l
xxxtu
Propertiesof Iff is convex then
convexfunctions
fix1 3f y tixy ⽽ fly function is supported
by
forany x and
y
hyperplane everywhere
nation
y
thedotproduct between the direction and gradient
fxitcg [Link] fix 㣈
Efg
Tutorial 7 i Recall ⽗兄 的 ⼗⼀ ⼆
Dufy i Úzfy
Substitute v x y
How Ky The direction vector
gg fix
⼆
tly xi [Link] a line of y
Remember the slope⼆ 点 㠭器淡
器笊 Think 对⼼ as the slope normalvector
andy x as the horizontal displacement
should be interpreted as
fix y xifx ⼥
currentvalue ⼀ horizontal displacement slope which is the way you describe a line
Why do take x T
we transpose y
Because
yx is a vector and fix is also a vector The hyperplane is
defined as all the possible vectors are perpendicular to fix
the normalueco
That's why there's a dot product to measure if a vector is perpendicular to
the normal vector
definit [Link]
sufficient
iii 箈 Tfcx
condition When we write
Ff x Yo we say that is Positive semi
2
convexity
of The Squared distance list [Link] is on ins
guarddistance 等 2 27 o
Optimality Hf is Convexand 妙 0
condition
对minimize ⼆
at M
then 对 is the r
off
⼥
ProofSuppose 对必 ⼆ Foranyx p the对化
fix fit textile fix
OptimalsolutionThemean_squared error is
of MSE L⼆⻰点 ⼼中 X⼀ yi
2
柰 ft in
iii
1
嘉 ⻬
家煎
⼀
品笑
煎 夔 庇江 炏
trongconvexity A function f isµ strongly convex if
A function is L
LThitziffiifykniiier fr
pschit [Link]
anyy x and
In words the function Values can
onlychange little for points that are
close
If you change x by a Little bit the functionvalue doesn'tchangemuch
yiǔg
Lecture 8 Optimization 2
Forlog ⼼了
⼼ log 1 expgi⼼中
we cannot solve 先⼆0
matesolutions We
zroxi
say that 分 is an approximate solution
if for a given E 0
optimization
Note that it is
ficlose f a
in function value not close in input
iii
riterative Howmany updates do we need to achieve
fcxti [Link]
it
an approximate solution
fxti ftiscriforo.rs1
[Link]
a
[Link]
11对⼼ ⼜
fyillELllxyllfixkfytix [Link]
of Based on mplications
of
definition smoothness and gradient update
moothnes
yi
fiiifiixt
choose E Xt
iiiiiiin
flxtni [Link] LyinAl
Xt 1 ⼆ ⽓t
[Link]
Xt 川⽓
f N t 11
Jt 1
Lgt Nfl Xt 川⽓ L smoothmaking
sure
In other words [Link] youalways
makingprogress
Theexpression [Link] a maximum 在 when gt⼆⻰ and reaches 0 when gt
Choosing any gtE Ii t is able to Strictly decrease the objective
Forsimplicity we choose yi Ì for the rest of the analysis
Guarantee
of If we do gradient descent on a L smooth andin_strongly convex fncti
[Link]
Given
illoflxtill fcx
radiantdescent
n fcxssfcxt [Link] 1 在11对1X ti HE
Ènofy112 fxt fly E f Xt fix 吉 f 妙 [Link]
⼀
1 吉 妙 fix f
1 吉⼋
Theconvergence rate is linear_ nni [Link]
If we do gradient descent on a Lsmooth convex function
[Link] a 唑等
forget
The convergence rate is sublinear
No proof needed
og
radiant on 毙 ⼆ 点 燓不怨 管派 c
[Link]
loss
itexpi j
⼆点 ll c
golcxn iu
of
size
hedataset
n hu
For mean_squared error recall that the solution for 器
w 中中⻔ 中 y
⼆0 is
tochasti [Link]
下 Sam t from data set S
descent 2 wttiiwt gt [Link] l is singleton lossfunction_onlymeasure
Rr Sample Lz loss [Link] wig 灬 _y i 10910的 atgivenpot
Per Sample log loss tcwix y [Link]
3 Go to T until the solution is satisfactory
[Link]
i I
radiantdescent where
ub
gradient A sub
gradient at x is a vector
g that satisfies his
set
ofg
3 fy fix tcgxig
for any y andthe set of sub gradients at x is denoted as Ǜǐi
Obviously Pfcx E Han if Tx
exists
Convergence theorems can be ported to sub gradient descent
Examples
fixX x2 is 2Strongly convex
fl M is Convex and 7 lipschitz
This also implies that mean_squared error is Strongly convex function
fix ⼆ 11姙 is 2Strongly convex
glx fix t ⽐吃 is strongly convex if f is convex
Lecture10 Neural Networks 1
hamster
cognitionwith
eruption
cìsionBoundary
ycx ⼆ [Link] o l x 式2X ⼀器
⼆⼀ [Link]
linear
discriminant
2D
eason
0
Boundary
[Link]
linear
discriminant
3D
of
raining A discriminantfor a two class problem
zupa
[Link]
eruption a⼼ ⼆⼼九⼗W ⼼义
nor correction where w we wT T 义 1 xT T
[Link] use wand x to denote wand x from now on
y X ⼆gla凶 ⼆
gcwīx
where
gia ⼆正 a o 1
if
1 zif oa Eo
a
ga activation transfer
D 11x y
function ⼆ Hia
ga forperception
Training set 了
[Link] [Link]
y i 10 7 targetvalue or label
Initialize w
Modify w if Xi was misclassified
utc wtgyi [Link] _learning rate
NB lnnmixi nixitgcgi
ycxiilllxi
raptron's eometrg. r
夕化字 wi
[Link]
correction
ycxinxilogal
gixijoyx yi
0 0
yi 1
1 1 0
[Link]
Whatabout convergence
Theperception learning algorithm terminates if trainingsamples are linear
separable
nearly Separable
us
nearly
nonseparable
optionstructures Wi 以 T
and gcxigcacx.
gcwTx xs 1 x 加
Boundaries asim where
gia if a so
1 if a to Cf sigmoid function
213
nnnānnnn
doesnt changetheLine
you a
logicalFunction
Question i
findthe weightsfor each function
Perception
or XOR
rceptro [Link]
and
elisionBoundaries
Eachedge is a node
gwixtw. et
⼆
[Link] y
workwith 三
ultipleoutput yklx glwixtwko
odes
剡州 11 11
iwiiii gg
K outputnodes y y N Bi we
wi
sometimes use
y
to denote j forsimplicity
ForXn⼆ Xno Xin T
jnk⼆g 总Wkdxkd glanky an ki 裘Wkdxnd
Limitationsof Single
layer perception is just a linear classifier
eruption Multi layer perception can form complex decision boundariespiecewiseLinea
but the Perception training algorithm is not applicable
data are Linearly non_separable
Training doesn't stop
if
Weights w are adjusted for
misclassified data only Lcorrectly classified da
are not considered at all
owcanwesolvethe problem
of training error
Use the least Squares criterion
for training
2
Ezlw zijn yn
Replace with a differentiable function
gl
What about removing gl in the hidden layers
big W
gcnixnn gnzgcwmixni [Link]
ga [Link]
⼆
⾯
Mapping ⼀内 to co 1
Use a threshold ⼆ 0.5 for binary classification
忐gcangiain gcani [Link]
utofNN
hresholdfunc us
gmoidfunc it
of
yNetworks
Universal Approximation theorem
and Univariate function and a set
ofaffinefunctionals can uniformly
approximate anycontinuous function
of n real variables with support in the
unit hypercube only mild conditions are imposed on theunivariate function
业
A single output node neural network with a singlehidden layer with a finite
neurons can approximate continuous functions
unconstrained
Lecture
9 Optimization 3
Optimization my Law
n example 在 如
Law
roblemwit [Link].lk1
constrains
is an example
of
a constrained optimization problem
Theinequality IN1124 is called a constraint
Solutions that satisfy the constraints are called feasible solutions
forsome ⼊了
Note that ⼩ E V_ S for all s
Since
gcx stint
for anyEL
⼊
Cui
where ⼊仁 [Link]
gci maximize
gix
Theproblem
gn
拟
器
⼊
⼊ 20
is called the dual problem
Its lagrangian is
F ⼆点忘卫 logput⼊ ⼼ ⺠只
Solving the optimality condition gives 器 ⼆点㐬卫w_wi É 卫 以 2
7_ 点 耘⼀点 _iiiniiiii
[Link]
⼆
忘义惑⼯ i 1 ⼊⼆⾔ˇ 上 i N
⼆
B ZuEV2⼀⼆⼆wi 1 1 1 [Link] lad check
Bk I ⼭__wi manytimes K occurs
Projection no
Ti
v
nuncos0 11
吤器叫 in
The projection of x onto w isn
If we have N data points x 加了 then the sum of the csquared
with
projection is
The sum
Ěfup ⼆
my wTXXTws.t.mn2 1
The Lagrangian is
F i i w ⼊ 1 11W们
Finding the optimalSolution gives
是 ⼆
XXTXIMW 2⼊w 0
ㄨㄨㄒ w ⼊w
It turns out that ⼊ is an eigenvalue and w is an eigenvector
Why ⼊
器 ⼆⼊
Since the
goal is to
find the maximal projection this is now equivalent to
I [Link] genuine f XX
The term
i is
called the Rayleigh quotient
The optimal w is called the first principal component
Lecture11 NeuralNetworks2
R sigmoid function_larger weight its sticker I 5
change the weight slopeof sigmoid function changes
Output of his du a
Single的 a network with a Single output node Logistics
igmo [Link]
activation function
pity where 点 f
ctNation ⼆ a⼆ Wi Xi
y g
fi m
⼆
⼀ 三品 知
interpretation
of output X X
Guinea
robability
of Ci ry
two class problem with classes
p p
C and Cz The
posteriorprobability
un
ofclassC
㦛 [Link]
京器 [Link]
⼆
1 ⼆
Approximation
f posterior
snobabilities
Training Training set D [Link] l XN where
yi E To ⻔
yN
single layer Error function
ural network En Ew 三点ljn yn 2
with MSE 2
it gcuixn y n
i Ěcgl感 wixni y n
2
兜 EmsECW
Optimization problems
No analytical solution
Employ an iterative method requires initial values
eg Gradient descent steepest descent Newton's method
Conjugate gradient method
Gradient descent
I wi
global minimum
Solution
Ii
try differentstartingpoints
raining EMSEl ⼼ ⼆点En where En ⼆
Íljn yniiilgcwixnis [Link]
ng gun
USEconti Where
in ⼆ gca an ⼆ Éwixi 器 Xní ⼀ ⼆
⼦
㦛 器 i
cjn gnio i
cjn [Link] X ni
trainingsampleof ith dimension
iggy
ugayǖ a
gun fin
Another Training problem with the mean squared erm CMSEs criterion with the
running Sigmoid function 2
Criterion ⼀ EmsEcw i
ljnyn 余 gcan
rossentropy
写
答 ⼆点 ljn [Link] gcanicl
Other Th
嚣 i
activation n
functions Mapping 0 内 C 1.1
器 籡 然 然 ⼆
⼆
ljnk [Link] g'tank X ni
0Ey differentiable
ii in ye
y
PCCklxsizbca
k0f
multilayer
wawii
lk Multi layer Perception MLP
Hidden to output weights
gi .Input.to_hidden
weights
wie wi 7 蕊
Écgiynk
2
hederivatives En
ffunction
the error
与 ⼆
an K ⼆ 杰Wǜznj
9CanK
[Link] [Link]⼆点 ni'xni
簽 靠 撡 撡 ⼆
⼼
El
ji_guk g'lGuk Znj
蕊 器 ⼀
i Ü
⼆
器
惠蕊 字 h bnjsxni
⼆ 1点link y nk g'cane nii J h'sbug X ni
Errorback
飍 靠 Ii
⼆
t
ropagatio
ljnk ynklgcankizn
[Link] ⼆ 装⽔
器
⼆
噵 恭 ti 惑ljnk
ynkigcankjwihibnpx
h'lb
.nl Xni
1 1 1
graph
entropy
layer
L
logjcz [Link] C is the true class a 4
亲 录 ⼀
⼆ I log
Ee ac ⼆
哥 ⼼
⼀ 卫i c
j 卫 in
器 g ⼆
[Link]
Derivatives
rule
ectors
of
derivatives
Lecture 13 Neural Network 3
Joblenswith
multi layer
auralnetworks
with EBP
Lecture14 Highdimension stats
dune ⽐ 以 me
of a ball with radius r is
volume is scaled
蕊
concentration
expnenw
[Link] d [Link]
we
shrinks
sǜiiiiiiig
by
a small amount E the volume
As d becomes
large V111 a r
is only a small fraction
of Vcr
fine
of a unit
Vu ⼆
器
T t ti ⼀⽂
⼩2不 É X
VII so when d so
Corners
of
he unit cube if
可
Volume near Pick a north direction
the equator Pick a so the width of a slab
灰⼼ 么me above is
about_e.dz
The volume is concentrated at the equator
Two random Dick a random vector u inside the unit ball
actorsinside Set u to be north
a unit ball Since most of the volume is concentrated at the equator another
random vector v will likely lies on the equator
The dot product civ is likely to be o Likely to be ortho
gonna
Thevolume is Concentrated at the Crust So Hull and Hull are
likely to be close to 1
The distance
of u and v is
likely to beabout 后
llx
yllillxllfzxgftllylit wrmofForanyx
[Link] closet
andom ing
Gaussian P 1 eiiexpli
vectors In words for anfine Nco I Ml is about da
Lecture 14 Generalization 1
Generalization is defined as being approximately correct on unseen
data most of the time
⼼ a Ex
p [Link] I
Thetest error Lsich a program h is an estimate
error LDch
of the generalization
of
The goal is tofind a program h with low generalization error LDch
m
I learning A Y H me take m Samples
㤠裂华 for
Approximately all q so and 0 8 ET Such that
aprogram bestprogram howfarawayfromthebest
p
The dataset
LpAcs
sisiimi
is alsorandom
[Link]器
的
of
want theprobability
awayfromthebestisSmu
Wecan say that our learningalgorithm A Can achieve at most 1 worsethan the
best of otherprograms this from 959 of the time
any of
ofreelunch Suppose Ix1 2m Forany learning algorithm A there is a distribution Dand
theorem
fix o 1 I such that f 0 but
Bin ILDAcs ⻰ ⽯⻰
The 2 and 10 are arbitrary constants
In words foreverylearningalgorithm there exists a task that it will fail_
Tradeoff When we compare to 㘩 best in H we are comparing
say we only
ga [Link]
complexityand
DSandsi notfrom same Distribution
Failure case 1 D H not largeenough minLinh not lowenough
generalization When His large min m H LDch becomes lower
When His the universe all function we cannot learn nofreelunchtheorem
of
H needs to be about the right size
Hcanbe a large but the range of A needs to be about the right Size
Forexample We can only run a finite number Steps with stochastic
of
gradient descent so the range we can explore is limited the
by
的⼼ ⼆ algorit m ⼼ ⼗
decomposition
⽓
器 箭器
垒念
应竿 之管 error
trainingerror tg
[Link] error
Uniform Convergence assures that the training error and generalization error
ǔff
are not
fartofrom each otherall
This has
requirement
happen
for 笑⽈
h EH the uniform part and a strong
Awe
state
forany [Link]
In particular
LDChERM E ni b chi t Za
If It has uniform convergence property then H is PAClearnable
with ERM
Lecture 15 Generalization2
AClearning
A灬
m 最 ⼼
裴
Uniform
Convergence
ch
Deompim
LDcln [Link]
chi
ǔibch's
Estimation error can be controlled
if we do ERM and have uniform
convergence
Approximation error can be controlled
by changingthe sizeof H
Generalization
Many not all generalization bounds have the following form
Bounds With probability 1 8 for an h E H
⼀
1
b ch ELscn 1亞 舉
n is number of
samples
CH is a capacity measure of H the sizeof ft
There is a family
ofuniform convergence results
ample Howmanysamples do we need to achieve a certain error
Complexity How large should n to get to E
⼩巠 顨
⼩ EE
In other words CCH
n o
VCgenerdizati.nlbounds_rn.nu
apnik Chervonenkis generalization
sounds 8 的⼼ ⼀
⼼ EU ⼼ z 占
d is called VC dimension
For linear classifiers H x [Link] [Link] H p 1
Formultilayer perceptions with p edges VC [Link] Ocplogp
These results are independent
of
learning algorithms
In particular it is independent of
how ERM is done
毙⾔毕n
[Link] chi Els ch 2 di
When His large minhEH Lsch can be low
When H is large d becomes
large
Capacity
eneralizatīon
tradeoff
Approximation error
Controlled
by capacity of H
Under
fitting A model is under fitting
training
if there is anothermodel that has a lower
A model h is under
The better f
fitting
is unknown unless we find if there is
fit such that [Link]
All models are underfitting with respectto ERM
When people fitting they simply men there is
say a model is under
room to improve the training error
Over
fitting A model is
if there
fitting
over is anothermodel that has a highertraining
error but a lower test error
A model his fitting
over
if there is f such that Ls
Lsf s chi and
Better
if Ls'ch
f is unknown unless we find it
Models Can over even
fiterror is though
the gap lls ch _Lich 1 between
training and test not large
When people
say a model is overfitting they simply mean there is
a large gap between training and tent error
thesis
typo Suppose we have a hypothesis class in 2D
un gzaxt
[Link]
iiiiiix x
lil
1x 1
Lecture16 Generalization 3
With Probability 1 8 for an hey
1tab
Capacity confidence
generalization
aug ch Esch
Ascapacity ofH increases mirisch drops but theSecond terms goesup
agehypothesis Compare ⼆
classes fl the set oftwo_layerneuralnetworks with 512 hidden units
tlzi the set of all two_layer neural networks
fl has a finite VC dimension while th hasinfinite
It is much easier c or tempting to reduce training error
by increasing the
hypothesis class
FailureCase Compare
2 W2 0.206 0.317
wq 30.69 93.21 2.65 3.29 0 [Link] 857I
Thelearned weight are either too large or to small for degree9
What if instead we optimize
⾄11WIFEwho
LsCW t Hwy2
新
笓 Tw Last who 7w Last
X [Link]
iWtiwt
The term EllWIR is called L2 regularize [Link] gtNWt
yt7wLLW kegularizatien
It is alsoknown as weight decay
Theexpression
Lsu tEllWIR
is the Lagrangian of
ginLscw
[Link]
lwllE TheLzregularizer
has an effectof controlling the capacityof the
hypothesis class
Compare
flyx [Link] WER M
fl 1x ⼼中 x Hulk
BI
Shatering Given in datapoints there are
A setof n points is shatteredby ft if there is
2
ways of label them
an arrangement
Itof 17
n point
such that classifiers in tf can Produce all 2 labeling
VC dimension is the largestnumber points that ft can Shatter
of
Rademacher Rademacher complexity in binary Classification on a dataset S is defined
complexity a
Raft ⼆ 区
器 去点 mx I iiiifiiiǜi
where one In [Link] chosen 器 瀏 了
爕
In words Rademachercomplexity measures how well a class of classifiers
correlate with random noise
Rademacher Complexity in
as
binary classifications for u points is defined
RsCH ⼆
Espn I Rs MI
dematcher With probability ⼤⼦ for all chhE tft ⼩熙
generalization LDch ELS Rnch
bounds With probability It for an hEM
ch Lsch t Rsch 3 藇
If Six 此 ⼼ 了 and fix mix nuns Bi
ǙǙǏǛĚ
Lin if
hypothesis class is bounded
fireRslH ⼆区 嘫 Ed 噩
Rsc
bounded
withbounded is H
坛器 a ⻄ now 讪 款 伛
⼀
⾿是墢 ⾅ x的 11九111
叫
ability If we replace a data point in the dataset do youget a very dffu
classifier
We say that the leaning algorithm is stable is changing a datapoint
does not change the classifier much
overf ES
DnILDIAcsn [Link] Eiwcn ItcAcs Xi
yi t Acs xi
y
y
䧇
唯 Acs ⾂ Ecxy [Link] y I
EsIEcxynDIllAcS lxi yi II
Es IS His Es IE nun It Acs Xi
if I
pschizloss If the losslipschizcontinuous
is P
1 ec x is Acsill
Acs
Xi
yi Acs yi EpHAis
Weonlyneed a bound on HAS以 ⼀Acs 11
hi has finite VC dimension while the last two has bounded Rademacher
complexity
Lecture 17 universal approximation
Universal Forany Eso given any Lips chit function f xEl 叫 1,1 there is a
Approximationnetwork
g such that lgcxi [Link] E forany
The number of nodes needed to achieve this is Ocd Tenralnetworks ispowfn
Polynomials are universal approximations
Decision trees are universal approximations
Universal approximation does not explain
why neural networks so special
i
DepthSeparation There exists functions which Can be approximated withsmall depth 3networks
but cannot be approximated with depth 2 networks without using 0129nodes
Functions to show these results tend to oscillate a lot
Some believe that the results are pathological anddonot happen in practice
VCdimension Infinite
offunction
a sin
iiiiiilfhfnho.u
[Link]
Universal Whatcan be implemented with polynomial numberofnodes
Approximation Any Turing machine that runs in T operations Canbe implemented with a
neural network
of depth OCTwith a total OCT nodes
Recall that VC dimensionneural networks is Oil El logl El where
of
E is the numberof edges in the network
and
ness
of Training a layer 3node neural network is NP complete
2
[Link] Overparameterization means using a lot more nodes than the numberof points
Over
parameterization helps optimization
interpolation Fitting a dataset to training error zero is called interpolation_
léducion
I
m Z
I
Applications
and
Considerations
rmcīpd Xm i Em [Link]
Component Zmxk ⼆Xmxd Udxk
Analysis Z 21 Ez Zk X x ⼈ ㄨd V u in ⼀ uKI
Zi Xu
uk ZiXu myVarEiI
myVarIXu. [Link]
u [Link]
⼆ [Link] xTx NxcovarianceofX
[Link] uiu ⼆⼗
my Varia my
uixu S.t.HU211
uzi 0 1
E Xuz z X V2
be Ex that correspond to second
Because u must eigenvector of
largest eigenvalue Ca
Summary XmxdA
SZmxkckcd ZmxkEXmxdUdxki
XmxdVdx
[Link]
亚 X Z加 x [Link] VKI
where columns
of Vdxk are the eigenvectors of Ex 5ㄨ
Lecture19 K means Clustering
不blem Aim i Identify Clusters data points in a
of multi dimensional space
mount Suppose we have data set 化 xz XNT as N observations of
a d dimensional variable x
Our goal is to partitiondata set into a known numberofclusters
say k
We formalize the idea by introducing ddimensional
can vectors
MkEll KI to represent each cluster
Specificgoal Given a K find an assignment data points to
2roble. g of
mum clusters and the Set of vectors Uk to represent these cluster
The assignment rule crnk 1 if Xn is in cluster k and all pics
are unknown
Ideally we points in each cluster to be close to
want the
each other and far from points in other clusters
8三点 三点 rnkllxnwui ⼈
fk Stu
⼆
点么k X El X2 Xn fuk 0
1 Random initialization
initialize
lowt pk 2 es are initiated to a subset
ofdata
3 Repeat clustering for various initial andselect the best set of us
4 K mean tt
Lecture20 Gaussian Mixture Models
Context Kmeans Solution
J 砻 hkllxn [Link]
云
Mk ⼆
器 ⻜
⼆ 三
器器器 ⼀
引
812 1 is the responsibility that component k takesin explaining the observation x
maximum Suppose we observe [Link] xi Xz XNI Assume that data points are
kelihood
Luton toGMM
drawn independently the likelihoodfunction
of all Ndata points is
lot ideal Pila f 三 ⼆
点 在NIXnltc.TK1
logEpa If I 3
Epdgfcz I
The logarithm
or equal to
of
the
the expected value
expected value
of
of [Link]
fz is always greaterthen
LM_ Let's define Ink to be positive and satisfying 三品 去 k 1
[Link] is some probability distribution over K components for the
Gans n th data T
T ⼆
笀点 log惑 [Link]
Ě log 在 NcxnlMe Ek 等
点 log惑 Ink 1Mt
⼆
飈
砒
⼆点 Enk I
器等 1
班 Jensen's 你后⼼ 作到 了 㼢 Igf I
inequality
L ⼆点leg Enk
l 炎 1
等 1 B
2点 End log
会
B ⼆点惑hklgnk⼗点惠[Link] 無惑[Link]
EM is an iterative process maximizingthe bound B until convergence
For each update we take the partial derivative
parameters Set it to zero and above
of
bound B wrt
EMSolution E 5吅 M step
for Gmm 不⼆ ⻰ Ei Ink
hi
管
䶛⿏⽣
到 ME
㠭
站
器 ⼀
⼭ 如 北叮
Ek ⼆ 呈笑千氵志
Lecture 21 i Expectation Maximization
aural latent Two Sets of random variables X and Z
ariableModel X captures all observed variables
Z captures an unseen hidden latent unobserved variables
Joint Probability model is parameterised by OE 0 as
pc X Z10
EMkey It
is hard to optimise for
marginally_likelihood
motion Typically it is easier to optimise the loglikelihood
for
d ng
complete
logpix10
my log PIX E 10
Jensen's Theorem
Inequality If f Rs R is a convex function and x is a random
variable then
Forexample fcx
Efx f 正⼼
x2is a convex function and Ex22 Ex
如 2
Ex oix
o
Cull
bac ing Fordiscrete probability distributions p and q on the same probability
space X
Divergence The KL divergence is defined by
KLCDnqp [Link]
up
KL Pdp 0
overbound Let q X be any discrete probability function on
Z fr
argnd
likelihood
logcpcxon lgEpix.tl0
log垚 ⼼ 等
1ㄍㄠ
evidence Evidence
i
Lower Bound
logpcxla
tcqoitkLIqllp EM
[Link] an initial 00d
2 Expectation Step
Let q Z Ep LE l X 0 以 givingthebestlowerbound at001d
⽐
⾔
辔品型笇
丁⼼ 㥃 ⼆
3 Maximization 9
qui arg 了⼼
哔
log up
ma
2
um
[Link] Likelihood estimation is easy
the relevant random variables
In caseof missing dataand or
if we observed the valuesofall
latent variables then Maximum
Likelihood estimation becomes hard
3 In suchcases it often Simpler but not the
EM algorithm
is a
lug faster to use
嗡嗡 ftp
溔景州⼗ 点传 ⾔ t
Q3 ca KLIplzlxilllplz IE Ezyz灬 10
g 器
⼆ 点 Ez pczixnllogpcxilzi logP IT
⼆ 点 Ez pulxi ly 叫坚
器
⼀点 EZ pczixnII 还
gl
-
志瓦 logPIX I ⼆ 点 logplxī
⼩会