cse446 kernels and kernelized perceptron winter 2015
play

CSE446: Kernels and Kernelized Perceptron Winter 2015 - PowerPoint PPT Presentation

CSE446: Kernels and Kernelized Perceptron Winter 2015 Luke Ze@lemoyer Slides adapted from Carlos Guestrin What if the data is not linearly


  1. CSE446: ¡Kernels ¡and ¡ ¡ Kernelized ¡Perceptron ¡ Winter ¡2015 ¡ Luke ¡Ze@lemoyer ¡ ¡ ¡ Slides ¡adapted ¡from ¡Carlos ¡Guestrin ¡

  2. What ¡if ¡the ¡data ¡is ¡not ¡linearly ¡separable? ¡ Use features of features of features of features….   x 1 . . .     x n     x 1 x 2   φ ( x ) =   x 1 x 3     . . .     e x 1   . . . Feature space can get really large really quickly!

  3. Non-­‑linear ¡features: ¡1D ¡input ¡ • Datasets ¡that ¡are ¡linearly ¡separable ¡with ¡some ¡noise ¡work ¡ out ¡great: ¡ ¡ x 0 • But ¡what ¡are ¡we ¡going ¡to ¡do ¡if ¡the ¡dataset ¡is ¡just ¡too ¡hard? ¡ ¡ x 0 • How ¡about… ¡mapping ¡data ¡to ¡a ¡higher-­‑dimensional ¡space: ¡ x 2 x

  4. Feature ¡spaces ¡ • General ¡idea: ¡ ¡ ¡map ¡to ¡higher ¡dimensional ¡space ¡ – if ¡ x ¡is ¡in ¡R n , ¡then ¡φ( x ) ¡is ¡in ¡R m ¡for ¡m>n ¡ – Can ¡now ¡learn ¡feature ¡weights ¡ w ¡ in ¡R m ¡ and ¡predict: ¡ ¡ y = sign ( w · φ ( x )) – Linear ¡funcXon ¡in ¡the ¡higher ¡dimensional ¡space ¡will ¡be ¡non-­‑linear ¡in ¡ the ¡original ¡space ¡ x → φ ( x )

  5. Higher ¡order ¡polynomials ¡ number of monomial terms d=4 m – input features d – degree of polynomial d=3 grows fast! d = 6, m = 100 d=2 about 1.6 billion terms number of input dimensions

  6. Efficient ¡dot-­‑product ¡of ¡polynomials ¡ Polynomials of degree exactly d d =1 � u 1 � v 1 ⇥ ⇥ � ⇥ � ⇥ φ ( u ) . φ ( v ) = = u 1 v 1 + u 2 v 2 = u.v . u 2 v 2 u 2 v 2 ⇤ ⌅ ⇤ ⌅ d =2 ⌃ ⇧ ⌃ 1 1 u 1 u 2 v 1 v 2 ⌃ = u 2 1 v 2 1 + 2 u 1 v 1 u 2 v 2 + u 2 2 v 2 ⌥ � ⌥ � φ ( u ) . φ ( v ) = ⌃ . ⌥ � ⌥ � 2 u 2 u 1 v 2 v 1 ⇧ ⇧ = ( u 1 v 1 + u 2 v 2 ) 2 u 2 v 2 2 2 = ( u.v ) 2 For any d (we will skip proof): φ ( u ) . φ ( v ) = ( u.v ) d K ( u, v ) = • Cool! Taking a dot product and an exponential gives same results as mapping into high dimensional space and then taking dot product

  7. The ¡ “ Kernel ¡Trick ” ¡ • A ¡ kernel ¡func*on ¡defines ¡a ¡dot ¡product ¡in ¡some ¡feature ¡space. ¡ ¡ ¡ ¡K ( u , v )= ¡ φ ( u ) Ÿ ¡ φ ( v ) ¡ • Example: ¡ ¡ ¡2-­‑dimensional ¡vectors ¡ u =[ u 1 ¡ ¡ ¡ u 2 ] ¡and ¡ v =[ v 1 ¡ ¡ ¡ v 2 ]; ¡ ¡let ¡ K ( u,v )=(1 ¡+ ¡ u Ÿ v ) 2 , ¡ ¡Need ¡to ¡show ¡that ¡ K ( x i , x j )= ¡ φ ( x i ) ¡ Ÿ φ ( x j ): ¡ ¡ ¡ K ( u , v )=(1 ¡+ ¡ u Ÿ v ) 2 , = ¡1+ ¡ u 1 2 v 1 2 ¡ + ¡ 2 ¡ u 1 v 1 ¡ u 2 v 2 + ¡u 2 2 v 2 2 ¡ + ¡2 u 1 v 1 ¡ + ¡ 2 u 2 v 2 = ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡ [1, ¡ u 1 2 , ¡ ¡ √ 2 ¡ u 1 u 2 , ¡ ¡ ¡u 2 2 , ¡ ¡ √ 2 u 1 , ¡ ¡ √ 2 u 2 ] ¡ Ÿ ¡ [1, ¡ ¡ v 1 2 , ¡ ¡ √ 2 v 1 v 2 , ¡ ¡ v 2 2 , ¡ ¡ √ 2 v 1 , ¡ ¡ √ 2 v 2 ] ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡ φ ( u ) ¡ Ÿ φ ( v ), ¡ ¡ ¡ ¡where ¡ φ ( x ) ¡= ¡ ¡ [1, ¡ ¡ x 1 2 , ¡ ¡ √ 2 ¡ x 1 x 2 , ¡ ¡ ¡x 2 2 , ¡ ¡ ¡ √ 2 x 1 , ¡ ¡ √ 2 x 2 ] ¡ • Thus, ¡a ¡kernel ¡funcXon ¡implicitly ¡ maps ¡data ¡to ¡a ¡high-­‑dimensional ¡space ¡ (without ¡the ¡need ¡to ¡compute ¡each ¡ φ ( x ) ¡explicitly). ¡ • But, ¡it ¡isn’t ¡obvious ¡yet ¡how ¡we ¡will ¡incorporate ¡it ¡into ¡actual ¡learning ¡ algorithms… ¡

  8. “Kernel ¡trick” ¡for ¡The ¡Perceptron! ¡ • Never ¡compute ¡features ¡explicitly!!! ¡ – Compute ¡dot ¡products ¡in ¡closed ¡form ¡K(u,v) ¡= ¡Φ(u) ¡ Ÿ ¡Φ(v) ¡ ¡ • Kernelized ¡Perceptron: ¡ • Standard ¡Perceptron: ¡ • set ¡a i =0 ¡for ¡each ¡example ¡i ¡ • set ¡w i =0 ¡for ¡each ¡feature ¡i ¡ • For ¡t=1..T, ¡i=1..n: ¡ • set ¡a i =0 ¡for ¡each ¡example ¡i ¡ – ¡ ¡ X a k φ ( x k )) · φ ( x i )) y = sign (( • For ¡t=1..T, ¡i=1..n: ¡ k y = sign ( w · φ ( x i )) – ¡ ¡ X a k K ( x k , x i )) ¡ = sign ( – if ¡y ¡≠ ¡y i ¡ – if ¡y ¡≠ ¡y i ¡ w = w + y i φ ( x i ) k • ¡ ¡ • a i ¡+= ¡y i ¡ • ¡ a i ¡+= ¡y i ¡ ¡ • At ¡all ¡Xmes ¡during ¡learning: ¡ Exactly the same ¡ X a k φ ( x k ) computations, but can use w = K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¡= ¡1×K(x 1 ,x)+0×K(x 2 ,x)+0×K(x 3 ,x)+0×K(x 4 ,x) ¡ x 2 ¡ 0 ¡ 4 ¡ 0 ¡ 4 ¡ ¡ ¡ ¡ ¡= ¡K([1,1],[-­‑1,1]) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡K(x 1 ,x) ¡ ¡ ¡ ¡ ¡= ¡(1x-­‑1+1x1) 2 ¡ x 3 ¡ 4 ¡ 0 ¡ 4 ¡ 0 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡K([1,1],x) ¡ ¡ ¡(because ¡x 1 =[1,1]) ¡ ¡ ¡ ¡ ¡ ¡ ¡ = ¡0 ¡ x 4 ¡ 0 ¡ 4 ¡ 0 ¡ 4 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡= ¡(x 1 +x 2 ) 2 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(because ¡ ¡ K(u,v) ¡= ¡(u Ÿ v) 2 ) ¡ ¡ ¡ ¡ ¡

  10. Common ¡kernels ¡ • Polynomials ¡of ¡degree ¡exactly ¡ d ¡ • Polynomials ¡of ¡degree ¡up ¡to ¡ d ¡ • Gaussian ¡kernels ¡ • Sigmoid ¡ ¡ ¡ • And ¡many ¡others: ¡very ¡acXve ¡area ¡of ¡research! ¡

  11. Overfipng? ¡ • Huge ¡feature ¡space ¡with ¡kernels, ¡what ¡about ¡ overfipng??? ¡ – Oqen ¡robust ¡to ¡overfipng, ¡e.g. ¡if ¡you ¡don’t ¡make ¡ too ¡many ¡Perceptron ¡updates ¡ – SVMs ¡(which ¡we ¡will ¡see ¡next) ¡will ¡have ¡a ¡clearer ¡ story ¡for ¡avoiding ¡overfipng ¡ – But ¡everything ¡overfits ¡someXmes!!! ¡ • Can ¡control ¡by: ¡ – Choosing ¡a ¡be@er ¡Kernel ¡ – Varying ¡parameters ¡of ¡the ¡Kernel ¡(width ¡of ¡Gaussian, ¡etc.) ¡

  12. Kernels ¡in ¡logisXc ¡regression ¡ 1 P ( Y = 0 | X = x , w , w 0 ) = 1 + exp ( w 0 + w · x ) • Define ¡weights ¡in ¡terms ¡of ¡data ¡points: ¡ X α j φ ( x j ) w = j 1 P ( Y = 0 | X = x , w , w 0 ) = 1 + exp ( w 0 + P j α j φ ( x j ) · φ ( x )) 1 = ¡ 1 + exp ( w 0 + P j α j K ( x j , x )) • Derive ¡gradient ¡descent ¡rule ¡on ¡ α j ,w 0 ¡ • Similar ¡tricks ¡for ¡all ¡linear ¡models: ¡SVMs, ¡etc ¡

  13. What ¡you ¡need ¡to ¡know ¡ • The ¡kernel ¡trick ¡ • Derive ¡polynomial ¡kernel ¡ • Common ¡kernels ¡ • Kernelized ¡perceptron ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend