apprentissage statistique - laboratoire d'informatique de paris...

249
Apprentissage Statistique Master DAC - Université Paris 6 P. Gallinari, [email protected], http://www-connex.lip6.fr/~gallinar/ Année 2014-2015

Upload: others

Post on 04-Jan-2020

3 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique

Master DAC - Université Paris 6P. Gallinari, [email protected], http://www-connex.lip6.fr/~gallinar/

Année 2014-2015

Page 2: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Plan du cours

Apprentissage Statistique - P. Gallinari2

Introduction Apprentissage à partir d’exemples Exemple introductif : le perceptron

Formalisation du problème d’apprentissage Apprentissage supervisé

Réseaux de neurones Machines à noyaux, machines à vecteurs de support

Réseaux de neurones profonds et apprentissage de représentations Réseaux récurrents Apprentissage non supervisé

Algorithme EM et mélange de densités Clustering spectral Factorisation matricielle

Quelques liens utiles

Page 3: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Introduction

Page 4: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage à partir d'exemples

Apprentissage Statistique - P. Gallinari4

3 ingrédients de base Données {z1, ..., zN} Machine Fθ Critère C (apprentissage et évaluation)

But Extraire de l'information à partir des données

Information pertinente pour la tâche étudiée pour d'autres données du même type

Utilisation Inférence sur de nouvelles données

Type d'apprentissage : Supervisé Non supervisé Semi supervisé Renforcement

Page 5: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Exemples - problèmes d'apprentissage

Apprentissage Statistique - P. Gallinari5

Parole / Ecriture Données : (signal, (transcription)) But : reconnaître signal Critère : # mots correctement reconnus

Conduite véhicule autonome Données : (images routes, (commande volant)) e.g. S. Thrun Darpa Challenge +

Google car But : suivre route Critère : distance parcourue

Recherche d'information textuelle Données : (texte + requête, (information pertinente)) – corpus d’apprentissage But : extraire l'information correspondant à la requête Critère : Rappel / Précision

Diagnostic dans systèmes complexes Données : (état capteurs + alarmes, (diagnostic)) But : diagnostic correct Critère : ?

Page 6: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Exemples - problèmes d'apprentissage

Apprentissage Statistique - P. Gallinari6

Modélisation d'utilisateur Données : (Traces utilisateur) But : analyser/ modéliser le comportement de l'utilisateur

Exemples : ciblage clientèle, aide navigation, publicité, recommandation, assistants personnels e.g. Google now

Critère : ? Evaluation : ? Example Google Now

Google Now keeps track of searches, calendar events, locations, and travel patterns. It then synthesizes all that info and alerts you—either through notifications in the menu bar or cards on the search screen—of transit alerts for your commute, box scores for your favorite sports team, nearby watering holes, and more. You can assume it will someday suggest a lot more.

Page 7: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Exemples - problèmes d'apprentissage

Apprentissage Statistique - P. Gallinari7

Plus difficile : Traduction Extraction d’information (e.g. Never-Ending Language/ Image Learning) Compréhension de texte / scène visuelle – extraction de sens Découverte dans bases de données ou bases de connaissances ....

Données : i.e. représenter l'information ??

But ??

Critère ??

Evaluation ??

Page 8: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Données : diversité

Apprentissage Statistique - P. Gallinari8

Page 9: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Données : quantitésYahoo! Data – A league of its own… U. Fayyad KDD’07

Apprentissage Statistique - P. Gallinari9

Terrabytes of Warehoused Data

25 49 94 100500

1,000

5,000

Amaz

on

Kore

a

Teleco

m

AT&T

Y! L

iveS

tor

Y! P

anam

a

War

ehou

se

Walm

art

Y! M

ain

war

ehou

se

GRAND CHALLENGE PROBLEMS OF DATA PROCESSING

TRAVEL, CREDIT CARD PROCESSING, STOCK EXCHANGE, RETAIL, INTERNET

Y! PROBLEM EXCEEDS OTHERS BY 2 ORDERS OF MAGNITUDE

Millions of Events Processed Per Day

50 120 2252,000

14,000

SABRE VISA NYSE Y! Panama Y! DataHighway

Page 10: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Données : quantitésPetabytes (10^15) (chiffres 2012)

Apprentissage Statistique - P. Gallinari10

Google processes about 24 petabytes of data per day Google Street View Has Snapped 20 Petabytes of Street Photos Telecoms: AT&T transfers about 30 petabytes of data through its

networks each day Physics: The experiments in the Large Hadron Collider produce

about 15 petabytes of data per year Neurology: It is estimated that the human brain's ability to store

memories is equivalent to about 2.5 petabytes of binary data

Page 11: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Big Data: Volume, Velocity, Variety, and Veracity http://www-01.ibm.com/software/data/bigdata/

Apprentissage Statistique - P. Gallinari11

Volume: terabytes, petabytes Turn 12 terabytes of Tweets created each day into improved product sentiment

analysis Convert 350 billion annual meter readings to better predict power consumption

Velocity: streams Scrutinize 5 million trade events created each day to identify potential fraud Analyze 500 million daily call detail records in real-time to predict customer churn

faster Variety: Big data is any type of data - structured and unstructured data such

as text, sensor data, audio, video, click streams, log files and more. New insights are found when analyzing these data types together. Monitor 100’s of live video feeds from surveillance cameras to target points of

interest Exploit the 80% data growth in images, video and documents to improve customer

satisfaction Veracity: Establishing trust in big data presents a huge challenge as the

variety and number of sources grows.

Page 12: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Gartner Hype Cycle: Big Data

Apprentissage Statistique - P. Gallinari12

Page 13: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari13

Page 14: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Data science (Wikipedia 2013)

Apprentissage Statistique - P. Gallinari14

Data science incorporates varying elements and builds on techniques and theories from many fields, including mathematics, statistics, data engineering, pattern recognition and learning,advanced computing, visualization, uncertainty modeling, data warehousing, and high performance computing with the goal of extracting meaning from data and creating data products. …..Data science seeks to use all available and relevant data to effectively tell a story ….

Data science is the practice of deriving valuable insights from data. Data science is emerging to meet the challenges of processing very large data sets i.e. "Big Data" consisting of structured, unstructured or semi-structured data that large enterprises produce. A domain at center stage of data science is the explosion of new data generated from smart devices, web, mobile and social media. ……data scientists rely heavily upon elements of statistics, machine learning, text retrieval and natural language processing to analyze data and interpret results.

Page 15: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Place de l’apprentissage

Apprentissage Statistique - P. Gallinari15

L’apprentissage constitue une brique dans le processus de fouille / traitement de données qui arrive souvent à la fin du processus qui est intégré dans une application ou dans le SI de l’entreprise

Les différentes étapes de l’analyse des données Collecte des données / stockage Prétraitement des données, étiquetage éventuel Analyses des données par des techniques exploratoires Mise au point et test de différents modèles d’apprentissage Evaluation

Page 16: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Domaines d’application en Data MiningExemples

Apprentissage Statistique - P. Gallinari16

Web recherche d'information, filtrage d'information extraction d'information textuelle : e.g. recherche, bibliothèques virtuelles, veille

technologique, Question Answering , ... Multi-média

image + son, vidéo Données d’entreprise

infos produits, infos clients, ciblage clientèle ... Analyse comportement

e.g. telecoms : serveurs web, accès services commerciaux, internet - intranet, aide accès information, publicité

Distribué Mobiles : personnalisation, accès information Capteurs distribués, objets connectés

Biologie - analyse de séquences, de structures Automobile ...

Page 17: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Challenges de l’apprentissage

Apprentissage Statistique - P. Gallinari17

Passage à l’échelle Quantité de données, taille données

Dynamicité Flux

Distribué Complexité des données et des problèmes

Données structurées standards (XML, RDF, SMIL, …), taxonomies

Web2.0 : découverte / analyse de relations !!

Nouveaux problèmes, nouveaux usages Adaptation rapide outils existants et création de nouveaux outils

Page 18: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

4 Familles d’algorithmes

Apprentissage Statistique - P. Gallinari18

Page 19: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Données dans la pratique de l’apprentissage

Apprentissage Statistique - P. Gallinari19

Distinguer les ensembles d’apprentissage

Mettre au point le modèle

de test Evaluer les performances du modèle appris

de validation Apprentissage de méta-paramètres

Remarque On fera en général l’hypothèse que toutes les données sont générées suivant une

même loi

Page 20: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage supervisé

Apprentissage Statistique - P. Gallinari20

Ensemble d'apprentissage Constitué de couples (entrée, sortie désirée)

, , … , , But Au moyen d'un algorithme d'apprentissage, découvrir l’association En

utilisant les données d’appprentissage Qui offre une bonne généralisation

i.e. si hors de l'ensemble d'apprentissage mais généré par le même phénomène

Utilisation discrimination, identification, prévision, approximation …

Page 21: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage non supervisé

Apprentissage Statistique - P. Gallinari21

Ensemble d'apprentissage Uniquement des données d’entrée , … ,

But Regrouper les données similaires Modéliser les données Découvrir des relations non spécifiées à l’avance entre les données

Utilisation estimation de densité, extraction de similarités

Page 22: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage semi supervisé

Apprentissage Statistique - P. Gallinari22

Ensemble d’apprentissage étiquetés – faible quantité

, , … , , non étiquetés – grande quantité

, … ,

But Extraire l’information des exemples non étiquetés utile pour l’étiquetage Apprendre conjointement à partir des deux ensembles d’exemples

Utilisation grandes masses de données où l’étiquetage est possible mais trop coûteux données qui évoluent implémentation rapide de systèmes génériques pour différentes instances d’un

problème

Page 23: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage par Renforcement

Apprentissage Statistique - P. Gallinari23

Ensemble d'apprentissage Couples (entrée, sortie désirée qualitative)

, , … , , Les xi peuvent être des séquences (temporal credit assignment), les di sont des

réponses qualitatives (e.g. 0,1), déterministes ou stochastiques.

But Apprendre des actions optimales

Utilisation commande, décision séquentielle, robotique, jeux, programmation dynamique,

applications web ou sociales, ...

Page 24: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Exemple introductif : Perceptron

Apprentissage Statistique - P. Gallinari24

Page 25: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Un exemple : Perceptron (1960 Rosenblatt)

Apprentissage Statistique - P. Gallinari25

(image from Perceptrons, Minsky and Papert 1969)

Le perceptron est utilisé pour la discrimination

La cellule de décision calcule une fonction à seuil : ∑ ∑ avec 1

Classe 1 : ∶ 1 Classe 2 : ∶ 1

Cellules d’association Cellule de décision

Page 26: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

L'algorithme du perceptron (2 classes)

Apprentissage Statistique - P. Gallinari26

C'est un algorithme à correction d'erreur si est constant : règle à incrément fixe si est fonction du temps : règle à incrément variable

Donnéesbase d’apprentissage , , 1. . , ∈ , ∈ 1,1

Outputclassifieur ∈ , décision ∑

Initialiser w (0)Répeter (t)

choisir un exemple, ,Si . 0alors 1

Jusqu'à convergence

Page 27: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Fonction discriminante linéaire

Apprentissage Statistique - P. Gallinari27

Surface de décision: hyperplan F(x) = 0 Quelques propriétés

w est le vecteur normal de l'hyperplan, il défini son orientation distance de x à H : / w0 = 0 : H passe par l'origine

. ∑ avec 1

Page 28: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Géométrie de la discrimination linéaire

Apprentissage Statistique - P. Gallinari28

W

F(x) < 0

F(x) > 0wxF )( F(x) = 0

Page 29: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Le perceptron effectue une descente de gradient

Apprentissage Statistique - P. Gallinari29

Fonction de coût ∑ . ., é

gradient

, … , avec ∑ ., é

Règle d’apprentissage

Demo http://lcn.epfl.ch/tutorial/english/

Page 30: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Cas multi-classes

Apprentissage Statistique - P. Gallinari30

Approche générale : one vs all p classes = p " problèmes 2 classes " : Ci contre le reste

construire p fonctions discriminantes Fi(x), i = 1 ... p

règle de décision: x Ci si Fi(x) > Fj(x) pour ji

crée une partition de l'espace d'entrée

chaque classe est un polygone avec au plus p -1 faces.

Régions convexes : limitation des classifieurs linéaires

Page 31: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Propriétés Probabilité de séparabilité linéaire (Cover 1965)

Apprentissage Statistique - P. Gallinari31

Entrée de taille n, m formes classées aléatoirement en 2 classes (dichotomie)

L(m,n) : nb de "vraies" dichotomies linéairement séparables : si m > n aucun sous espace engendré par n + 1 formes n'est de dimension n - 1. si m n aucun sous espace de dimension m - 2 ne contient les m formes.

P(m,n) : probabilité qu'une dichotomie soit linéairement séparable.

n im

m

nm siC

nm si nmL

0 1

2),(

P m n

m n

C m nmmi

n( , )

1

211

0

si

si

0 2 4

n1

10

m/n+1

P(m,n)

0.5

1

Page 32: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Propriétés Théorème de convergence du perceptron (Novikov 1962)

Apprentissage Statistique - P. Gallinari32

Si ∃ :∀ , R

les données peuvent être séparées avec une marge , i.e. supmin .

l'ensemble d'apprentissage est présenté au perceptron un nombre suffisant de fois

Alors après au plus / corrections, l'algorithme converge

Page 33: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Propriétés Borne sur l'erreur de généralisation (Aizerman et al. 1964)

Apprentissage Statistique - P. Gallinari33

Si les données sont séparables elles sont en nombre infini règle arrêt : après la kème correction, les

données présentées sont reconnues correctement

alors le perceptron converge en l / /

étapes avec une probabilité 1 , l'erreur de test est <

Page 34: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Overtraining / généralisation en regression

Apprentissage Statistique - P. Gallinari34

Exemple (Bishop 06)

Necessité de controler lors de l’apprentissage la complexité des modèles Techniques de régularisation

Page 35: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Algorithmes d'apprentissage numérique

Apprentissage Statistique - P. Gallinari35

Il existe un grand nombre d’algorithmes et de familles d’algorithmes pour les différents problèmes génériques abordés en apprentissage

Il existe de nombreuses implémentations sous forme de programmes dédiés ou de logiciels plus généralistes

Quelques exemples populaires Données statiques

Supervisé Réseaux de neurones Arbres décision / régression, random forest Fonctions noyau, machines à vecteurs supports Nombreux modèles pour l’estimation de densité paramétrique, non paramétrique

Non supervisé Modèles à variables latentes

Modèles latents probabilistes Factorisation matricielle

Données structurées Séquences

Réseaux de neurones récurrents, modèles Markoviens Arbres et graphes

Modèles relationnels

Page 36: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Formalisation du problème de l'apprentissage

Page 37: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Formalisme probabiliste

Apprentissage Statistique - P. Gallinari37

Données vecteurs aléatoires générés suivant une densité

Machine d’apprentissage avec les paramètres du modèle à valeur dans un espace réel

Coût pour la machine et l’exemple

Risque théorique

Solution optimale ∗

Page 38: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage à partir d'exemples

Apprentissage Statistique - P. Gallinari38

Données ..

Risque empirique ∑

Principe inductif Le principe inductif défini le processus d'apprentissage Exemple : Minimisation du risque empirique

La fonction ∗ qui minimise le risque théorique est approximée par qui optimise le risque empirique

C’est le principe que l’on utilise dans une grande partie du cours

Est-ce un bon principe ?

Propriété de généralisation ?

Page 39: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Problèmes d'apprentissage : exemples

Apprentissage Statistique - P. Gallinari39

Discrimination , , ∈ 0,1 ensemble des fonctions à seuil R : probabilité de mauvaise classification C : fréquence des erreurs

Régression , , ∈R un ensemble de fonctions réelles R : espérance des erreurs quadratiques C : somme des erreurs quadratiques

Estimation de densité

ensemble de fonctions réelles R : espérance C : vraisemblance

0si 1sinon

Page 40: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage supervisé

Préliminaires : gradient, regression, regression logistiqueModèles discriminantsRéseaux de neurones

Machines à noyaux

Page 41: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage supervisé

Optimisation par gradientRegression

Regression logistique

Page 42: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari42

L’apprentissage supervisé recouvre un ensemble de problèmes génériques Regression Classification Ranking …

Dans le première partie du cours on examine des problèmes de régression et de classification

Page 43: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

OptimisationAlgorithmes de gradient

Apprentissage Statistique - P. Gallinari43

Objectif Optimiser une fonction de coût C(w) dépendant de paramètres w Principe :

Initialiser w Itérer jusqu’à convergence

1 la direction de descente D, le pas de gradient sont déterminés à partir d'informations

locales sur la fonction de coût C(w), i.e. approximations au 1er ou 2nd ordre.

Exemple :

Gradient de la plus grande pente (batch)Ensemble d’apprentissage

, , … , ,

Initialiser Itérer

1 t)Critère d’arrêtAvec ∑

Page 44: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Autres procédures de minimisation basées sur le gradient

Apprentissage Statistique - P. Gallinari44

Approximation quadratique locale de la fonction à optimiser (on approxime C par une parabole)

Avec H le Hessien de C(.) :

En différentiant par rapport à w

On cherche le minimum de C

Méthode de Newton

Trop couteux en pratique (O(n3) pour l’inverse, + dérivées partielles)

)()(21)()()()( 00000 wwHwwwCwwwCwC TT

0)( wC

)( 01

0 wCHww

)()()( 00 wwHwCwC

Page 45: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari45

En pratique on utilise des gradients du 1er ordre ou des approximations du 2nd ordre

Exemple approximation du 2nd ordre : Méthodes de quasi-Newton : approximation de H-1 itérativement.

Forme générale :

H' : approximation de 1 sans calculer les dérivées secondes

))(),(,,,'('')('

001

00

wCwCwwHFHHwCHww

ttt

t

Page 46: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Regression

Apprentissage Statistique - P. Gallinari46

Regression simple Objectif : prédire une fonction réelle Ensemble d’apprentissage

, , … , , ∈ , ∈ : regression simple

Modèle linéaire . ∑ avec 1

Fonction de coût Moindres carrés

∑ .

Gradient de la plus grande pente

, , …,

∑ . ∑ .

∑ .

Page 47: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Regression

Apprentissage Statistique - P. Gallinari47

Géométrie des moindres carrés

0

5

10

15

20

0

50

100

150

200

0 2 4 6 8 10 12 14 16 18 20

Page 48: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Regression multi-variée

Apprentissage Statistique - P. Gallinari48

Le modèle s’étend directement au cas où ∈ On a alors p regressions linéaires indépendantes L’algorithme est identique

Page 49: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Interprétation probabiliste

Apprentissage Statistique - P. Gallinari49

Modèle statistique de la regression . , où est une v.a. qui modélise l’erreur

On suppose que est une v.a. i.i.d. gaussienne ~ 0, , exp

La distribution a posteriori de d est alors | ; exp .

Vraisemblance ∏ | ;

C’est une fonction de w, calculée pour un ensemble de données, ici les données d’apprentissage

Principe du maximum de vraisemblance Choisir le paramètre qui maximise ou toute fonction croissante de

on va maximiser la log vraisemblance qui donne des calculs plus simples

∑ . On retrouve le critère des moindres carrés

Sous les hyp. précédentes, on a une interprétation probabiliste de la régression

Page 50: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Regression logistique

Apprentissage Statistique - P. Gallinari50

La regression linéaire peut être utilisée pour des problèmes de regression ou de classification

Un modèle mieux adapté pour la classification (avec des sorties binaires) est celui de la régression logistique

..

Fonction logistique

La fonction

est appelée fonction logistique ou sigmoide

hint 1

0

0,2

0,4

0,6

0,8

1

-5 -4 -3 -2 -1 0 1 2 3 4 5

sigmoid

Page 51: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Regression logistiqueInterprétation probabiliste

Apprentissage Statistique - P. Gallinari51

Comme ∈ 0,1 , on va faire l’hypothèse d’une distribution conditionnellede Bernouilli

1 ; et 0 ; 1 En plus compact

; 1 avec ∈ 0,1

Vraisemblance

∏ 1

Log-vraisemblance ∑ 1 log 1

Gradient de la plus grande pente

∑ Algorithme

Page 52: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Regression logistique multivariée

Apprentissage Statistique - P. Gallinari52

On suppose que l’on a un problème de classification à plusieurs classes 1…p On les code suivant la fonction indicatrice suivante

Classe 1: 1,0, … , 0 Classe 2 : 0,1, … , 0 … Classe 1: 0,0, … , 1 On a un vecteur de sorties à p dimensions – codage “one out of p”

La fonction est une fonction vectorielle à p dimensions La composante i sera une fonction softmax

.

∑ .

Attention : ici ∈ est un vecteur

Le modèle probabiliste sous jacent est un modèle multinomial pour les densitésconditionnelles

; = .∑ .

Algorithme d’apprentissage Comme précédement on peut utiliser un algorithme de gradient pour maximiser la log

vraisemblance

Page 53: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage supervisé

Réseaux de neurones

Page 54: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Réseau de neurone - description informelle

Apprentissage Statistique - P. Gallinari54

Caractéristiques

Ensemble d’éléments simples interconnectés Echange d'information au moyen des connexions Calcul/ mémoire distribués

Page 55: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apports pluridisciplinaires

Apprentissage Statistique - P. Gallinari55

Domaines Neurosciences Sciences cognitive (AI, psychologie, linguistique) Informatique Maths Physique

Buts Modélisation (neurophysiologie, biologie.....) Modèle de calcul (applications, computational theory, apprentissage...)

Page 56: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Fondements biologiques

Apprentissage Statistique - P. Gallinari56

Le neurone Soma Arbre des dendrites Axone Flot d'information

axone : impulsions électriques

dendrites : transmission chimique avec le soma via synapses

Synapses contact : émission - réception Poids synaptique = modulation de l'information transmise vers le soma. Comportement du neurone + mémoire ?

Page 57: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Exemple : réseau linéaire

Apprentissage Statistique - P. Gallinari57

Etat (cellule) = ΣcellulesW incident*état(cellules incidentes )

Apprentissage Dynamique Caractéristiques :

Architecture : interconnexion + définition unités Algorithmes : apprentissage + dynamique

Visible units Hidden units

SIGNAL DECISIONW

W

WW

W

WW

WW

1

2

3

4

5

6

78

9

Visible units

Page 58: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Neurones et Types de neurones

Apprentissage Statistique - P. Gallinari58

Page 59: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Composants du neurone

Apprentissage Statistique - P. Gallinari59

Page 60: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Historique rapide des réseaux de neurones

Apprentissage Statistique - P. Gallinari60

43 Mc Culloch & Pitts : neurone formel "A logical calculus of the ideas immanent in nervous activities"

40 – 45 Wiener (USA) Kolmogorov (URSS) Türing (UK) Théorie de l'estimation et de la prédiction (contrôle batteries anti-aeriennes)

Boucle de rétro-action

Page 61: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari61

48 – 50 Von Neuman : réseaux d'automates 49 Hebb : apprentissage dans les réseaux d'automates 55 – 60 Rosenblatt : Perceptron Widrow - Hoff : Adaline

70 – 80 Mémoires associatives, ART, SOM ... 90 – 95

Réseaux non linéaires Réseaux de Hopfield, Machine de Boltzmann

Perceptron multicouches ...

2006 - .. Deep neural networks, restricted Boltzmann machines,… Representation learning

Page 62: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Optimisation dans les RNAlgorithmes de gradient

Apprentissage Statistique - P. Gallinari62

Principe : 1 la direction de descente D, le pas de gradient sont déterminés à partir d'informations

locales sur la fonction de coût C(w), i.e. approximations au 1er ou 2nd ordre.

Exemples :

Plus grande pente (batch) Initialiser Itérer

1 t)Critère d’arrêtAvec ∑

Gradient adaptatif (on line – stochasticgradient)

initialiserIterer

choisir un exemple 1

Critère d’arrêt

Page 63: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Le neurone formel

Apprentissage Statistique - P. Gallinari63

C'est un automate caractérisé par l’espace des signaux d'entrée , … , ∈ une

fonction de transition

Fonctions de transition Historiquement, fonction à seuil (Neurone formel de McCulloch et Pitts)

En pratique on utilise des fonctions différentiables Soit ∑ , on considère des fonctions de la forme Fonction identité g

Fonction sigmoïde g

Fonction tangente hyperbolique g

On verra par la suite d’autres fonctions de transition

x2

x1

xn

y = F(x)

Page 64: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Gradient stochastique et Adaline

Apprentissage Statistique - P. Gallinari64

On suppose que l’on est dans un contexte « en ligne » Les données arrivent et sont traitées séquentiellement Les paramètres sont modifiés pour chaque donnée Gradient stochastique (Robbins-Monro, 1951), popularisé pour les réseaux de

neurones par (Widrow et Hoff, 195X)

Que l’on compare avec l’algorithme batch

Gradient adaptatif (on line – stochasticgradient)

InitialiserIterer

choisir un exemple1

Critère d’arrêt

Plus grande pente (batch)

Avec ∑

Initialiser Itérer

1 t)Critère d’arrêt

Page 65: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Adaline

Apprentissage Statistique - P. Gallinari65

Neurone linéaire Risque empirique : moindres carrés

∑ .

Page 66: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Adaline : règle de Widrow-Hoff

Apprentissage Statistique - P. Gallinari66

x(t) est l'exemple présenté à l'instant t, le gradient est calculé sur le coût local A comparer avec le gradient classique qui calcule le gradient sur le risque empirique

initialiser 0Iterer

choisir un exemple 1 .

Critère d’arrêt

Plus grande penteinitialiser 0Iterer

1 ∑ .Critère d’arrêt

Page 67: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari67

Apprentissage hors ligne vs apprentissage adaptatif

ck erreur sur la forme k de l'ensemble d'apprentissage

Gradient sur C Gradient adaptatif sur c

Q qk

W W

k

kcN

C 1

Page 68: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Optimisation dans les RNAlgorithmes de gradient

Apprentissage Statistique - P. Gallinari68

Les algorithmes d’optimisation pour les réseaux de neurones utilisent souvent ces techniques simples de gradient stochastique

Raisons Historique Complexité et taille de données Ces méthodes sont devenues populaires également pour de nombreux autres

modèles (complexité) Ils exploitent bien la redondance présente dans les données

Bien adaptés aux grandes dimensions

En pratique utilisation d’algorithmes « mini-batch » À chaque itération on considère un petit sous ensemble des données

Page 69: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Perceptron Multicouches

Apprentissage Statistique - P. Gallinari69

Réseau avec : des couches externes: entrée et sortie des couches internes dites cachées Les cellules sur les couches internes et la couche de sortie sont des fonctions

sigmoïdes ou tangente hyperbolique.

y

x

Input

Output

hidden layers

d

Page 70: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Perceptron Multicouches

Apprentissage Statistique - P. Gallinari70

Les exemples sont présentés séquentiellement Inférence : passe avant

Pour chaque exemple on calcule la sortie

Apprentissage : passe arrière On calcule l’erreur entre sortie désirée et sortie calculée. On propage cette erreur pour calculer le gradient des poids du réseau

Page 71: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari71

Notations vecteur activation de la couche i activation du neurone j de la couche i

matrice de poids de la couche i à la couche i+1 poids de la cellule k sur la couche i à la cellule j sur la couche i+1 vecteur de sortie

1 1

Page 72: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Inférence : passe avant

Apprentissage Statistique - P. Gallinari72

Pour un exemple x On calcule en parallèle les activités de la couche de neurones 1

puis )

Avec ,

On utilise les sorties de la couche 1 comme entrées de la couche 2 et on calcule en parallèle les activités de la couche 2

puis )

1 1

Page 73: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage : passe arrière

Apprentissage Statistique - P. Gallinari73

On décrit l’algorithme dans le cas d’une fonction de coût moindre carrés

On présente un exemple , , ∈ , d ∈ On calcule la sortie , ∈

Calculer l’erreur , … , Rétropropager cette erreur de la couche de sortie vers la couche d’entrée :

∆ mise à jour des poids par sgd

∆ gradient pour

C’est cette quantité « » que l’on va rétropropager

2 ′ si i est une cellule de sortie

∑ ′ si i n’est pas une cellule de sortie

Page 74: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari74

Remarques Comme pour la passe avant, on modifie tous les poids d’une couche en parallèle C’est une implémentation particulière de l’algorithme du gradient stochastique

qui évite de dupliquer les calculs Elle peut être adaptée à toute fonction différentiable Fonctions de coût

Pour des tâches de regression : LMSE

Pour des tâches de classification, différentes fonctions employées Entropie croisée Hinge, logistique (cf slide suivant)

Page 75: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Fonctions de coût Différentes fonctions de coût sont

utilisées, suivant les problèmes, oules modèles

LMSE Regression

Souvent utilisé en classification

Classification, Hinge, logistique Classification Exemples

∈ , ∈ 1,1 Hinge, logistique sont ici des

approximations de l’erreur de classification

Apprentissage Statistique - P. Gallinari75

Figure from Bishop 2006

En abscisse : . (marge)

, | |, 1 . max 0,1 .

, ln 1 exp .

Page 76: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Contrôle de la complexité

Apprentissage Statistique - P. Gallinari76

En pratique, on n’optimise jamais le risque empirique seul On optimise le risque tout en controlant la complexité

cf partie théorique du cours

Nombreuses méthodes Régularisation (Hadamard …Tikhonov)

Théorie des problèmes mal posés

Minimisation du risque structurel (Vapnik) Estimateurs algébriques de l’erreur de généralisation (AIC, BIC, LOO, etc) Apprentissage bayesien

Fournit une interprétation statistique de la régularisation

Le terme de régularisation apparait comme un a priori sur les paramètres du modèle

Méthodes d’ensembles Boosting, bagging, etc

….

Page 77: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Regularisation

Apprentissage Statistique - P. Gallinari77

Hadamard Un problème est bien posé si

Il existe une solution Elle est unique La solution est stable

Exemple de problème mal posé (Goutte 1997)

Tikhonov Propose des méthodes pour transformer un problème mal posé en problème

bien posé

Page 78: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Régularisation

Apprentissage Statistique - P. Gallinari78

Principe: Contrôler la variance de la solution en contraignant la fonctionnelle F Optimiser C = C1 + C2(F) C est un compromis entre

C1 : mesure du but poursuivi e.g. MSE, Entropie, ... C2 : contraintes sur la forme de la solution (e.g. distribution des poids)

: poids de la contrainte Moindres carrés régularisés

On reprend le cas de la regression linéaire simple

∑ . ∑ 2 régularisation , 1 régularisation connu aussi sous le nom de « Lasso »

Fig. from Bishop 2006

Page 79: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari79

Résoudre

∑ . ∑ , 0

Revient à résoudre le problème d’optimisation sous contrainte ∑ .

Sous contrainte ∑ s pour une certaine valeur de s

Effet de cette contrainte

Fig. from Bishop 2006

Page 80: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Régularisation empirique pour les réseaux de neurones

Apprentissage Statistique - P. Gallinari80

∑ biaise la solution en diminuant les poids inutiles

∑ 2 groupes de poids autour de c

∑ 1 ∑ cellules cachées h + poids

Utiliser des contraintes différentes suivant le rôle des poids Problème : détermination des "hyper-paramètres"

Page 81: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Autres idées pour le problème de la généralisation dans les réseaux de neurones

Apprentissage Statistique - P. Gallinari81

Arrêt de l'apprentissage Elagage : tuer les paramètres inutiles dans un réseau. Différentes mesures d'utilité

ont été proposées Bruiter les entrées (Matsuoka 1992 ; Grandvallet et Canu 1994 ; Bishop 1994) Réseaux à convolution

Page 82: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Exemple (Cibas et al, 95, 96)

Apprentissage Statistique - P. Gallinari82

Discriminer entre trois classes de "formes d’onde". Les trois formes de base pour la génération des formes d'onde :

3 classes C1, C2, C3 engendrées respectivement par :

u v. a. de densité uniforme sur [0,1], ~ N(0,I), Classes équiprobables Apprentissage = 10 ensembles disjoints, chacun de 300 exemples Test = 5000 exemples Algorithme : Rétropropagation

1 5 9 13 17 21

6 6 6

h 3

h 2h 1

26)(1

10)(1

2)(1

32

31

21

huuhx

huuhx

huuhx

Page 83: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Evolution des performances pendant l'apprentissage

Apprentissage Statistique - P. Gallinari83

Sans régularisation

Figure 1 a (left), b (right): evolution of the performances (mean square error) duringtraining for MLPs with a varying number of hidden units. (a) corresponds to a stochastic gradient descent and (b) to a conjugate gardient. Each curve corresponds to a two weight layer MLP, the number on the curve gives the size of the hiddenlayer.

0

5

10

15

35

60

5

10

15

3560

Page 84: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Evolution des performances pendant l'apprentissage

Apprentissage Statistique - P. Gallinari84

Avec régularisation

Comparaison de l’erreur en apprentissage (a) et en généralisation (b) pour les réseaux h=15 et h=60 en minimisant le coût ordinaire sans terme de régularisation (...-ord) et le coût avec la régularisation: avec détermination des paramètres à priori (...-WD) et en les estimant pendant l’apprentissage (...-estim)

h=60-WD

h=15-estim

h=60-estimh=15-ord

h=60-ord

h=60-ord

h=15-ord

h=15-estimh=60-estimh=60-WD

Page 85: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Fonctions à Base Radiale

Apprentissage Statistique - P. Gallinari85

Réseau à deux couches Notations

wi. = poids vers la cellule i, xi sortie de la cellule i, x entrée

Risque : moindres carrés

Couche de sortie

g = IdCouche intermédiaire

y

x

j jj xwwA 0

2wxA

2)( A

eAg

2

.0)( jj ijiii wxgwwxGy

Page 86: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

La fonction sigmoïde

Apprentissage Statistique - P. Gallinari86

Distribution de la famille exponentielle :

q, f : paramètres de la loi, ( q paramètre de position , f paramètre de dispersion). Ex. de distributions exponentielles : normale, gamma, binomiale, poisson,

hypergéométrique ... Hypothèse : la distribution des données conditionnellement à chaque classe est

de la famille exponentielle, avec un paramètre de dispersion identique pour toutes les classes i.e. :

Alors

)),()())/(((),,( xcabxxp T exp

)),()())/((()/( xcabxCxp iT

ii exp

)(1

1)/(bxwi T

exCP

Page 87: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Capacités d'approximation des PMC

Apprentissage Statistique - P. Gallinari87

Résultats basés sur les théorèmes d'approximation de l'analyse fonctionnelle. (Cybenko (1989))

Théorème 1 (regression): Soit f une fonction saturante continue, alors l'espace des fonctions de la forme ∑ . . est dense dans l’espace des fonctions continues sur le cube unité C(I). i.e. ∀ ∈ ∀ 0, ∃ ∶ sur I

Théorème 2 (classification): Soit f une fonction saturante continue. Soit F une fonction de décision définissant une partition de I. Alors ∀ 0, il existe une fonction de la forme ∑ . . et un ensemble ⊂ tel que 1 (D)

sur D .

(Hornik et al., 1989) Théorème 3 : Pour toute fonction saturante croissante f, et toute mesure de

probabilité m sur , l'espace des fonctions de la forme ∑ . .est uniformément dense sur les compacts de - espace des fonctions continues sur

Page 88: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari88

Fonctions radiales (Park & Sandberg, 1993) Théorème 4 : Si f, fonction réelle définie sur Rn est intégrable, alors l'espace des

fonctions de la forme :

est dense dans L1(Rn) ssi .

Nj

j

jj

wxfvxg 1

. )(.)(

nR

dxxf 0)(

Page 89: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari89

Résultats basés sur le théorème de Kolmogorov Théorème sur la représentation (exacte) des fonctions réelles de Kolmogorov

Toute fonction h de C(I) peut s'écrire sous la forme

où les fonctions g et f sont des fonctions continues d'une variable.

Théorème 6 (Kurkova 1992) Soit h dans C(I), n 2 et R+, alors quelquesoit m vérifiant

m = 2n + 1n/(m-n) + v < / ||h||h(1/m) < v(m - n)/(2m - 3n)v > 0

h peut être approximée à une précision par un perceptron possédant deux couches cachées de fonctions saturantes et dont les sorties sont linéaires. La première couche comprend n.m(m+1) unités et la seconde m2(m+1)n. Les poids sont universels sauf ceux de la dernière couche, pour toutes les fonctions f vérifiant :

f(d)= sup{|f(x1, ..., xn) - f(y1, ..., yn)|, x, y I et |xp - yp| < p}.

))((),...,( 121 11

nq

np ppqqn xfgxxh

Page 90: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Interprétation probabiliste des sorties

Apprentissage Statistique - P. Gallinari90

Risque théorique

Le min de R est obtenu pour ∗ | Coût théorique C pour la famille de fonction

C ,

C , ,

∗ | est bien la solution optimale Dans l’espace des hypothèses, w* / R(w*) = Minw C minimise simultanément :

, LMSE

, meilleure approximation LMS de |

Page 91: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari91

Cas de la Classification d = (0,…, 0, 1, 0, …, 0) avec un 1 en ième position si classe i

i.e. ∗ meilleure approximation LMS de la fonction discriminante de Bayes (solution optimale).

de façon générale avec des sorties binaires ∗ 1

Coût : di =ij pour x Cj, = coût de la décision i quand la classe est j hi* est le risque conditionnel de la décision i Décision : sortie la plus faible.

L’importance de la précision sur les sorties dépend de l'utilisation (classification OU estimation de probabilité conditionnelle).

)/(]/[ 1 xjPxdE mj iji

Page 92: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage supervisé

Machines à noyaux

Apprentissage Statistique - P. Gallinari92

Page 93: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Introduction

Apprentissage Statistique - P. Gallinari93

Familles de machines d'apprentissage générales qui exploitent l'idée suivante : Projeter les données dans un espace de grande dimension - éventuellement infini

-où le problème sera facile à traiter Utiliser des "projections" non linéaires permettant des calculs "efficaces"

Exemples : Machines à Vecteurs Support (généralisent : hyperplan optimal, cadre Vapnik)

Processus Gaussien (généralisent : régression logistique, cadre Bayesien)

Page 94: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Perceptron : formulation dualehyp: 2 classes linéairement séparables, sorties désirées -1, 1

Apprentissage Statistique - P. Gallinari94

Perceptron primalInitialiser 0 0Répeter (t)

choisir un exemple, ,si . 0alors 1

Jusqu'à convergence

Fonction de décision

,

: nombre de fois où l’algorithme a rencontré une erreur de classification sur

Perceptron dualInitialiser , ∈Répeter (t)

choisir un exemple, ,soit :si ∑ . 0alors 1

Jusqu'à convergence

Fonction de décision

.

Matrice de Gram matrice NxN de terme i, j : .matrice de similarité entre données

Page 95: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Représentation Duale

Apprentissage Statistique - P. Gallinari95

La plupart des machines à apprentissage linéaires ont une représentation duale Exemples

Adaline, regression, regression ridge, etc L’information sur les données est entièrement fournie par la matrice de

Gram : . , … , qui joue un rôle central

La fonction de décision F(x) s’exprime comme une combinaison linéaire de produits scalaires entre la donnée d’entrée x et les exemples d’apprentissage

Les machines à noyau généralisent ces idées Une fonction noyau K est définie sur x (on suppose ∈ ) par

, Φ , Φoù Φ est une fonction de dans un espace muni d’un produit scalaire

Page 96: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Produit Scalaire et Noyaux

Apprentissage Statistique - P. Gallinari96

Projection non linéaire dans un espace de grande dimension H (en général dim H >> n, et peut même être infinie) Φ: → avec ≫

Machine linéaire dans H - Primal : ∑ Φ

Machine linéaire dans H - Dual : ∑ Φ , F x ∑ Φ .Φ ,

Calculer les produits scalaires dans l'espace initial : choisir F / Φ .Φ , F x ∑ ,

avec K : fonction noyau (i.e. symétrique)

Page 97: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari97

Généralise le produit scalaire dans l'espace initial Le calcul de F ne dépend pas directement de la taille de H : les

calculs sont faits dans l'espace initial. La machine linéaire dans H peut être construite à partir d'une

fonction K sans qu'il soit nécessaire de définir explicitement : en pratique, on spécifiera directement K.

Cette idée permet d'étendre de nombreuses techniques linéaires au non linéaire: il suffit de trouver des noyaux appropriés Exemples

ACP, Analyse discriminante, regression, etc

Page 98: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Caractérisation des noyaux

Apprentissage Statistique - P. Gallinari98

Quand peut on utiliser cette idée ? Cas d'un espace fini

Soit , … , , , une fonction symétrique sur X, K est une fonction noyau ssi la matrice x dont l’élément (i, j) est , est positive semi-définie (valeurs propres 0 ou 0∀ )

Cas général : Conditions de Mercer (noyaux de Mercer) Il existe une application et un développement

ssi est fini

1)'(.)()',(

iii xxxxK

dxxgg 2)(/

0')'()()',( dxdxxgxgxxK

Page 99: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Caractérisation des noyauxEspace de Hilbert à noyau autoreproduisant Une fonction K: X*X R qui est soit continue soit définie sur un domaine fini peut

s’écrire sous la forme d’un produit scalaire :

avec Φ : x Φ(x) F espace de Hilbert

ssi c’est une fonction symétrique et toutes les matrices formées par la restriction de K à un échantillon fini sur X sont semi-définies positives).

Résultat à la base de la caractérisation effective des fonctions noyaux

Il permet de caractériser K comme un noyau sans passer par Φ C’est une formulation équivalente aux conditions de Mercer

)(),(),( zxzxK

Apprentissage Statistique - P. Gallinari99

Page 100: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

L’espace de Hilbert associé à K :

Le produit scalaire défini sur cet espace :

l

iiiii liRXxNlxKF

1..1,,,/,.)(

l

ijj

n

jii

l

ijiji

n

j

n

jjj

l

iii

zfxgzxKgf

xKgxKf

1 11 1

11

)()(),( ,

,.)((.) ,,.)((.)Soient

Apprentissage Statistique - P. Gallinari100

Page 101: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Noyau auto-reproduisant

Si on prend g(.) = K(x,.), alors

)(),( ,.)(,1

xfxxKxKfl

iii

Page 102: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Exemples de noyaux

Apprentissage Statistique - P. Gallinari102

2 d de polynomes des ensemble ss i.e.

),)2(,).(()(/ avec )().(),(

).(),(

21n

: 2 d de monomes les tousi.e.

).()(/)( avec )().(),(

).)(.(.),(

.),(

,1,1,,

2

,1,,

1,

2

1

2

ccxxxx(x)zxzxK

czxzxK

xxxxzxzxK

zzxxzxzxK

zxzxK

niinjijiji

njijiji

n

jijiji

n

iii

Page 103: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari103

Exemples de noyaux

).(

gaussien noyau exp

d ordred' polynome )1.(

),(2

cxvxSigmoïde

xx

xx

xxK

i

i

di

i

Page 104: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Construction des noyaux en pratique

Apprentissage Statistique - P. Gallinari104

Les résultats de Mercer servent à prouver les propriétés des fonctions noyaux. En pratique, elles sont peu utiles

Pour construire des noyaux, on procède par combinaison à partir de noyaux connus

Si K1 et K2 sont des noyaux sur X2, K3 défini sur F, les fonctions suivantes sont des noyaux : K(x, z) = K1 (x, z) + K2 (x, z) K(x, z) = K1 (x, z) . K2 (x, z)* K(x, z) = aK1 (x, z) K(x, z) = K3 (Φ(x), Φ(z)) …..

Page 105: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Machines à vecteurs support

Apprentissage Statistique - P. Gallinari105

Exposé du cours : discrimination 2 classes Cas général : discrimination multi-classes, régression, densité Idées

Projeter -non linéairement- les données dans un espace de "très" grande taille H Faire une séparation linéaire de bonne qualité dans cet espace Raisonner dans H, mais résoudre le problème d'optimisation dans l'espace de

départ (noyaux)

Page 106: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari106

Notion de marge

WxF )(

W

Wb

H : F(x) = W.x + b = 0

Marge géométrique pour xi :

Marge de W pr à ens. D :Mini(M(xi))

Hyperplan de marge maximale :

MaxW(Mini(M(xi)))

)()(Wbx

WWdxM iii

Page 107: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Marge géométrique vs marge fonctionnelle

Apprentissage Statistique - P. Gallinari107

Marge géométrique di.F(xi)/||w||

Marge fonctionnelle di.F(xi)

Remplacer w par k.w ne change pas la fonction de décision ou la marge géométrique, mais change la marge fonctionnelle.

Pour les SVM, on fixera la marge fonctionnelle à 1 et on optimiserala marge géométrique.

Page 108: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Prémisses : Séparation linéaire à hyperplan optimal (1974)

Apprentissage Statistique - P. Gallinari108

Hyp : D linéairement séparable

Fonction de décision : F(x) = W.x + b Pb apprentissage :

trouver l'hyperplan optimal H* qui sépare D i.e. di.F(xi) 1 , i

avec une marge maximale M =

i.e. : Problème Primal :

1 avec , 1.. i

Niii ddxD

wwxFd ii

i

1)(.min

1)(...

Minimiser 2

ii xFdCS

W

Page 109: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari109

Solution : w* dépend uniquement des points supports i.e. points sur la marge qui vérifient : di.F*(xi) = 1

Rq: Quelque soit la dimension de l'espace, le nombre de degrés de liberté est "égal" au nombre de points de support

F* dépend uniquement du produit scalaire xi.x

support support

i i .x)(* x*i i

ii

ii xdxFdw

Marge

Vecteurs Supports

Page 110: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari110

Apprentissage :

On résoud le problème d'optimisation dit dual :

Problème minimisation quadratique sous contraintes

0et 0.

.)( Maximiser

ii

,

ii

ji

jjji

ii

dCS

xxddL ii

Page 111: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Machines à vecteurs supports

Apprentissage Statistique - P. Gallinari111

Faire une séparation à marge max. dans un espace défini par une fonction noyau.

Tous les résultats sur le classifieur linéaire à marge max. se transposent en remplaçant par .xxi

),( xxK i

bxxKdxF

xxKxx

bxxdxFxdW

RR

SVx

ii

i

SVx SVx

ii

iii

i

pn

i

i i

..

.. ..

),()(

)',()'().(

)()()( )(

:

Page 112: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari112

Apprentissage : On résoud le problème d'optimisation dual :

Problème minimisation quadratique sous contraintes dans l ’espace de départ Difficile en pratique : différents algorithmes. Dans la solution optimale i > 0 uniquement pour les points support.

Seuls les produits scalaires K apparaissent, et pas les .

0et 0.

),()( Maximiser

ii

,

ii

ji

jijiji

ii

dCS

xxKddL

Page 113: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Propriétés de généralisation -exemples

Apprentissage Statistique - P. Gallinari113

Th 1 peu de points support meilleure généralisation indépendant de la taille de l'espace de départ

Th 2 Si l'hyperplan optimal passe par l'origine et a pour marge

Alors

Dans les 2 cas, E[P()] est l'espérance sur tous les ensembles de taille l-1, et E[membre droit] est l'espérance sur tous les ensembles d'apprentissage de taille l (leave one out).

1ageapprentissexemples#supports]vecteurs[#))](([

ExerreurPE

qxNiq i ,1../

N

][))](([

2

2

qExerreurPE

Page 114: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Cas non linéairement séparable

Apprentissage Statistique - P. Gallinari114

Marges molles L'algorithme est instable

Dans les cas non linéairement séparables Dans le cas de données réelles même linéairement séparables Solution adoptée en pratique

autoriser des erreurs, i.e. prendre pour contraintes :

ηi = 0, xi est correctement classifié et est du bon coté de la marge

0 < ηi <= 1, xi est correctement classifié, est à l’intérieur de la marge

ηi > 1, xi est mal classé

ηi : slack variable

0

1))(.(

i

iii bxWd

Page 115: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

But Maximiser la marge tout en pénalisant les points qui sont mal classés

Formalisation Plusieurs expressions possibles du problème L’une des plus courantes :

C fixé par validation croisée joue le rôle de paramètre de régularisationNi

NibxwdCS

CwwMin

ii

N

i

..1,0 ..1,1).(

..

marge) lamax (i.e. ).(

i

i

1

i

Apprentissage Statistique - P. Gallinari115

Page 116: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Marges molles – formulation duale

0et 0.

),()( Maximiser

ii

,

ii

ji

jijiji

ii

dCCS

xxKddL

Apprentissage Statistique - P. Gallinari116

Page 117: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Algorithmes d’optimisation Algorithmes d’optimisation standard pour la programmation

quadratique sous contrainte e.g. Sequential Minimal Optimization (SMO)

Algorithmes stochastiques - SVM Results –(Bottou 2007) Task : Document classification - RCV1 documents belonging to the class

CCAT (2 classes classification task) Programs SVMLight and SVMPerf are well known SVM solvers written by Thorsten Joachims.

SVMLight is suitable for SVMs with arbitrary kernels. Similar results could be achieved using Chih-Jen Lin‘s LibSVM software. SVMPerf is a specialized solver for linear SVMs. It is considered to be one of the most efficient optimizer for this particular problem.

Algorithm (hinge loss) Training Time Primal cost Test Error

SVMLight 23642 secs 0.2275 6.02%

SVMPerf 66 secs 0.2278 6.03%

Stochastic Gradient (svmsgd) 1.4 secs 0.2275 6.02%

Stochastic Gradient (svmsgd2 1.4 secs 0.2275 6.01%Apprentissage Statistique - P. Gallinari117

Page 118: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Annexe : OptimisationProblèmes sous contraintes égalités, inégalités

Apprentissage Statistique - P. Gallinari118

Soient , , ,…, , , ,…, des fonctions définies sur à valeur dans

On considère le problème primal suivant (pb. 0) :

Fonction objectif Région admissible ∈ Ω: 0, 0 , région de Ω où f est définie

et les contraintes vérifiées

* est un minimum global si il n’existe pas d’autre point tel que ∗ , c’est un optimum local si ∃ 0: ∗ , sur la boule ∗

Une contrainte 0 est dite active si la solution w* vérifie ∗ 0 et inactive sinon

La valeur optimale de la fonction objectif (solution du pb. 0 est appelée la valeur du problème d’optimisation primal)

, ∈ Ω ⊂Sous contraintes

0, 1, … ,k noté 00, 1,… ,m noté 0

Page 119: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari119

est convexe pour ∈ si ∀ ∈ 0,1 , ∀ , ∈ , ∀t ∈ [0,1], 1 1

Un ensemble Ω ⊂ est convexe si ∀ , ∈ , ∀t ∈ [0,1], 1 ∈Ω

Si une fonction est convexe, tout minimum local est un minimum global Un problème d’optimisation pour lequel Ω est convexe, la fonction objectif

et les contraintes sont convexes est dit convexe

Page 120: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Optimisation non contrainte

Apprentissage Statistique - P. Gallinari120

Th. Fermat

Une C.N. pour que w* soit un min. de , ∈ est ∗

0

Si f est convexe c’est une Condition Suffisante

Page 121: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Optimisation avec contraintes égalitésLagrangien

Apprentissage Statistique - P. Gallinari121

Optimisation avec contraintes égalité (pb 1):

On définit le Lagrangien , associé à ce problème par, ∑

les sont les coefficients de Lagrange

Rq Si ∗ est une solution du problème d’optimisation sous contrainte, ll est possible

que ∗

0

, ∈ Ω ⊂Sous contraintes

0, 1, … ,m noté 0

Page 122: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Optimisation avec contraintes égalités

Apprentissage Statistique - P. Gallinari122

Th. Lagrange Une CN pour que ∗, soit solution de (pb. 1), avec , ∈ est

∗, ∗

0

∗, ∗

0

Si , ∗ est une fonction convexe de , c’est une condition suffisante

Rq La première condition donne un nouveau système d’équations

La seconde donne les contraintes

Page 123: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Optimisation sous contraintes égalité + inégalités - Lagrangien augmenté

De même, on définit le Lagrangien augmenté pour le pb. 0 :

,

Page 124: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari124

Formulation duale du problème d’optimisation Le problème d’optimisation dual correspondant au problème primal pb 0 est :

, min∈

, ,

Sous contrainte 0

Max , estappelélavaleurdudual

Rq : inf∈

, , est une fonction de , uniquement

Propriété : la valeur du dual est bornée supérieurement par la valeur du primalmax, ,

min∈

, , min∈

max, ,

, ,

Dans certains cas, on a égalité, cf dualité forte

Page 125: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari125

Théorème de dualité forte Etant donné un problème d’optimisation

, ∈ Ω ⊂Sous contraintes

0, 1, … ,k noté 00, 1,… ,m noté 0

où les et les sont affines (

alors les valeurs du primal et du dual sont égales

Les conditions d’existence d’un optimum sont données par le théorème de Kuhn et Tucker

Page 126: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

OptimisationTh. Kuhn et Tucker

On considère (pb. 0) avec Ω convexe et f C1 convexe, gi, hj affines (h = A.w+ b)

Une CNS pour que w* soit un optimum est qu’il existe α* et β* :

La formulation duale est une alternative à la formulation primale qui peut se révéler plus simple à traiter

kikiwg

kiwg

wLw

wL

i

i

ii

..1,0*..1,0*)(

..1,0*)(*

0*)*,*,(

0*)*,*,(

Apprentissage Statistique - P. Gallinari126

Page 127: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari127

Rq

La 3e condition dite condition complémentaire de Karush-Kuhn-Tucker implique que pour une contrainte active ∗ 0 alors que pour une contrainte inactive ∗ 0 Soit une contrainte est active ( ∗ 0 et gi(w*) = 0), w* est un point frontière de la

région admissible

Soit elle est inactive (αi* = 0) et w* est dans la région admissible

Si le point solution w* est dans la région admissible (contrainte inactive) alors les conditions d’optimalité sont données par le th. de Fermat et ∗ 0. Si il est sur la frontière (contrainte active), les conditions d’optimalité sont données par le th. de Lagrange avec ∗ 0.

Page 128: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

SVM – formulations primale et duale SVM

Ω, f, contraintes sont convexes, L est quadratique On étudie le cas, D = {(xi ,di)}i = 1..N linéairement séparables

Formulation similaire pour le cas non linéairement séparable Pb. Primal

Lagrangien primal

Lagrangien dual

Avec 0 dans les 2 cas

Nibxwd

CSwwMin

ii ..1,1).(

.. marge) lamax (i.e. ).(

Apprentissage Statistique - P. Gallinari128

N

i

iii bxwdwwbwL

1)1).((.

21),,(

N

i

jiji

jiN

ii xxddbwL

11).(

21),,(

Page 129: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

SVM – formulations primale et duale Pb. Dual

Fonction de décision

Ni

d

xxddbwL

i

N

ii

i

N

i

jiji

jiN

ii

..1,0

0

scontrainte les sous

).(21),,(Max

1

11

VSi

ii

i bxxdxF.

*).(**)*,,(

Apprentissage Statistique - P. Gallinari129

Page 130: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Deep Neural Networksand Representation Learning

Apprentissage Statistique - P. Gallinari130

Page 131: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Brief history

Apprentissage Statistique - P. Gallinari131

Deep learning was popularized by Hinton 05 with a model called Restricted Boltzmann Machines

Idea Train several successive layers in an unsupervised way, stack them, stick a classifier at

the last layer and do back propagation

Developed by different actors Bengio 06, LeCun 06, Ng 07 And many others now

Success story Very active domain, technology adopted by big actors (Google, Facebook, Msoft ..) Success in many different academic benchmarks for a large series of problems

Image / scene labeling

Speech recognition

Natural language processing

Translation

etc

Page 132: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Motivations

Apprentissage Statistique - P. Gallinari132

Learning representations Handcrafted versus learned representation

Very often complex to define what are good representations

General methods that can be used for different application domains

Multimodal data

Multi-task learning

Learning the latent factors behind the data generation Unsupervised feature learning

Useful for learning data/ signal rerpesentations

Several families of techniques Matrix factorization, dictionary learning, compressed sensing Latent probabilistic models (deep) Neural networks are the focus of this course

Page 133: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Complement to the NN course

Apprentissage Statistique - P. Gallinari133

Page 134: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

More units

Apprentissage Statistique - P. Gallinari134

In addition to the logistic or tanh units, already seen in the NN course, other forms may be used – some of the popular forms are: Rectifier linear units

max 0, . Rectifier units allow to draw activations to 0 (used for sparse representations)

Maxout max .

Generalizes the rectifier unit There are multiple weight vectors for each unit

Softmax Used for classification with a 1 out of p coding (p classes)

Ensures that the sum of predicted outputs sums to 1

Page 135: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Mean square error and maximum likelihood

Apprentissage Statistique - P. Gallinari135

Remember the following result concerning minimization of MSE

Mean square loss

Min of R is obtained for ∗ | MSE for a family of function

C ,

C , ,

∗ | is the optimal solution to Minw C w* / R(w*) = Minw C minimizes simultaneously:

, LMSE

, best LMS approximation of |

Page 136: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Mean Square error maximum likelihood

Apprentissage Statistique - P. Gallinari136

Statistical model of the regression , where is a random variable modeling the error (variability)

Let be a i.i.d. Gaussian random variable

~ 0, , exp

The posterior distribution of d is | ; exp

Likelihood ∏ | ;

Maximum likelihood Choose the parameter qui maximizing or alternatively any increasing function

of such as

log likelihood ∑

Under normal hypothesis on | ; , maximizing the likelohood is equivalentto minimizing the MSE loss

Page 137: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Cross-entropy loss – 2 classes

Apprentissage Statistique - P. Gallinari137

2 classes classification problem Target is 1 ∈ , 0 ∈ We consider a discriminant function

Here we take, F

with . , i.e. logistic function

The posterior probability of a class is a Bernoulli distribution and can be written 1

target output, computed output

Likelihood

∏ 1 Loss: negative log-likelihood

∑ 1 log 1 ∑ log for the Bernoulli distribution y |

This is the cross entropy between the target and computed posterior class distributions The minimum is obtained for ∀ 1. . This cross entropy loss could be used also when the targets are not binary but in the range 0,1 It can be shown that the optimal solution to the minimization of L is 1| this

means that (with the logistic function F) the learned will approximate this posterior probability

Page 138: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Cross-entropy loss – multiple classes

Apprentissage Statistique - P. Gallinari138

p mutually exclusive classes One considers a 1 out of p target coding scheme

i.e. the target has a 1 at the position corresponding to the class and 0 elsewhere e.g. 0,1,0, … , 0 if ∈ 2

log ∑ only 1 term is non 0 in this sum

Negative log likelihood ∑ ∑

Which is equivalent to ∑ ∗ with ∗ the output corresponding to ∗=1

Minimum when ∀ 1… Activation function: softmax

The outputs must be in 0,1 and sum to 1

∑ with . ,

Again this for is also suitable for targets in 0,1 that sum to unity This is called the multinoulli distribution

can be interpreted as the posterior probability of class k

Page 139: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari139

More generally, a probabilistic interpretation of NNs (and otherparametric models) can be obtaind by considering for the lossfunction a negative log-likelihood , d log p d If d is a continuous variable and we make the hypothesis that it is conditionnally

gaussian with mean , we get the MSE loss If d is binary and we make the hypothesis that it is conditionnally Bernoulli with

probability 1| we get the cross entropy loss

For multiple outputs One has to specify the form of the joint distribution of the output variables

conditionally on e.g. conditional independence

, … , ∏ |

Page 140: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Auto-encoders

Apprentissage Statistique - P. Gallinari140

Page 141: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Auto-encoders

Apprentissage Statistique - P. Gallinari141

This is a neural network (MLP) trained to reproduce the inputs at the outputs Early attempts date back to the 80s with the auto-associative memories (Kohonen) Renewed interest since 2006 for learning representations and for deep learning

Basic scheme

Neurons in the hidden and output layers could be of any type In the following one will assume hat units are sigmoid (but any differentiable function could be

used) Note that when using saturating functions like sigmoids, the values shall be coded in a fixed

interval [0, 1] for sigmoids Otherwise use linear ouput units

encoder f

decoder gcode h

input

output

Page 142: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Auto-Encoders - Training

Apprentissage Statistique - P. Gallinari142

Training set , … , this is unsupervised learning

The transition function of the AE is ∘ is called the encoder, is the decoder, is the code of

Loss function different functions can be used such as Mean Square Error or cross Entropy for example

Algorithm Auto-Encoders can be trained with back propagation, using the s both as inputs and outputs The auto-encoder will try to reproduce the input, i.e. to learn the identity function

In order to avoid this trivial solution, one will impose constraints on the hidden layer Undercomplete representations

One possible constriant is to limit the number of hidden units The A-E will learn a compressed representation of the data by exploiting the correlation among the features, this is

called undercomplete representation rq: if all units are linear, AE trained with MSE performs a transformation similar to PCA, i.e. it will learn the

projection that maximizes the variance of the data (without the orthogonal property, of PCA but this can be easilysolved

Overcomplete representations More recently, other constraints have been used with a hidden layer that may be even larger than the input layer When the representation is larger than the input space, itis called overcomplete representation

Page 143: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Learning overcomplete representations

Apprentissage Statistique - P. Gallinari143

In order to learn overcomplete representations different constraints have been proposed either on the form of the learned F function or on the hidden units Sparse auto-encoders

A sparse representation is a representation such that for a given , only a small number of the values in are non zero

Sparse representations have some desirable properties e.g. it allows the mapping F to respond differently to different regions in the input space,

i.e. hidden units specialize on some input regions (see manifold interpretation) This corresponds to learning local mappings

This is usually implemented through constraints operating on the hidden units

Contractive auto-encoders

this encourages the derivative to be close to 0, so that h is not sensible to variations in x except in the directions where this is meaningful

Prior on the distribution of hidden units Under a probabilistic interpretation of the NN, priors can play the role of constraints

Dropout Specific heuristic effective for large NN

Page 144: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Sparsity

Apprentissage Statistique - P. Gallinari144

Sparsity is often imposed using a regularization term in the loss function C = C1 + C2(F) With constraining the activation of towards 0

Different penalization terms may be used to enforce sparsity norm Kullback Leibler divergence penalty

C ∑ 1 log 1 The summation is over the hidden units the hidden units are assumed sigmoid (values in [0,1]) and is the activation of hidden unit i is the mean value of over the training examples s is a sparsity parameter, typically set at a low value e.g. 0.05 Kulback Leibler divergence between 2 discrete distributions P and Q is a dissimilarity

measure between these 2 distributions | ∑ log

| 1 log is KL divergence between 2 Bernoulli distributions of means s et h

Kullback Leibler divergence penalty forces the mean value of the hidden units to be close to sand thus to have a low mean value

Page 145: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari145

Derivatives for back propagation Note that these sparsity terms are defined on the activations of the training data Computing them thus requires a forward pass through the training set in order

to compute the required average values Then these mean values can be used for computing the gradient of these loss

function

Page 146: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Visualizing hidden units activities

Apprentissage Statistique - P. Gallinari146

One way to understand what a hidden unit (or any unit) is doing isto look at its weight vector

We consider here unit activations based on dot products likesigmoid or tanh units

Example (image from A. Ng cite)

Auto-encoder trained on a small set of 10x10 images 100 hidden units Each square represents the (normalized) weights of a hidden unit Grey value indicates the weight value Each hidden unit has learned a feature detector

Here mostly image edges (gradient) detectors

at different angles and positions

Page 147: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Probabilistic interpretation of auto-encoders

Apprentissage Statistique - P. Gallinari147

The loss criteria can be given a probabilistic interpretation If we make the hypothesis of the existence of a conditional output

distribution,the training objective is log |

If the conditional distribution is gaussian we get MSE, if it is a Bernoulli, xe get the cross entropy loss

For sparse auto-encoders A prior distribution on the hidden unit vector, corresponds to a regularization

term for the loss e.g. Laplace prior on corresponds to the regularization on the hidden units

activity

log ∑ log ∑ | | Note that all penalty terms do not need to have a prior interpretation (e.g. cross

entropy on h)

Page 148: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Combining auto-encoders with a classifier

Apprentissage Statistique - P. Gallinari148

The features learned can be used as inputs to any other system Instead of using the input features use Example for classification

1. train an autoencoder , … , → ,… ,

2. use the codes to train a classifier , , … , , Assuming here a 3 class problem

Both NN (encoder and classifier) can be trained separately using stochastic gradient descent

e.g. sigmoid units(logistic classifier)

Page 149: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Join training of the auto-encoder and the classifier

Apprentissage Statistique - P. Gallinari149

Fine tuning Separate training of each layer can be used as initialization Then stack the coding and classification layers one upon the other and fine tune

the new NN using back propagation as in a classical MLP

initialize

initialize

Page 150: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Deep auto-associators

Apprentissage Statistique - P. Gallinari150

Idea train successive layers of auto-associators in the hope of learning more complex

features of the inputs

Strategy (greedy layer wise training) Each auto-associator will be trained using the representation layer of a previous auto-

associator

The encoding layer of the different netwoks will then be stacked

After that fine tuning can be performed as before for a classification task

Why not learning all the layers at once Vanishing gradient

The gradients propagated backwards diminish rapidly in magnitude so that the first layers will not learn much

Non linear form of the loss function: many local minima

Page 151: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Deep architectures

Apprentissage Statistique - P. Gallinari151

autoassociators can be stacked Plus fine tuning using the last hidden layer if this is relevant for the task

Page 152: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari152

Why using auto-association Unsupervised learning

Often easy to get very large quantities of unlabeled data

Allows the extraction of « meaningful » features

These features can be used as preprocessing for other learning machines (e.g. classification) and for other datasets (same type of data but with differentcharacteristics or another density distribution)

e.g extract meaningful image feature extractors on a large dataset that can be used for other image datasets

Supervised fine tuning Can be used with other datasets when labels are available for the latter

Today, there exists procedures for training deep NN architectures from scratch

Page 153: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

CNN: Convolutional Neural Nets

Apprentissage Statistique - P. Gallinari153

Page 154: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Local connections

Apprentissage Statistique - P. Gallinari154

In many cases, data exhibit local properties, i.e. short term or spacedependencies between characteristics e.g. images, speech signal

Instead of computing global statistics via fully connected layers, one may use local connections This also allows the reduction of the number of parameters

Page 155: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Shared connections: convolutions

Apprentissage Statistique - P. Gallinari155

Local connections may be constrained to have the same weightvector This is called shared weights This is equivalent to convolve a unique weight vector with the input signal

Think of a local edge detector for images

This reduces even more the number of free parameters In the figure, colors indicate a weight value, here the 3 hidden units share the same

weight vector

Page 156: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Shared connections: convolutions

Apprentissage Statistique - P. Gallinari156

Several convolution filters can be learned simultaneously This corresponds to applying a set of local filters on the input signal

e.g edge detectors at different angles for an image Here colors indicate similar weight vectors

Page 157: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Pooling

Apprentissage Statistique - P. Gallinari157

The number of extracted features on the hidden layer can be verylarge if one uses several filters

In order to reduce this number, one may use pooling This consists in aggregating statistics for these features over a region of the signal Pooling operator : max, mean of the input units For an image or a spatial signal, pooling of features generated by the same

convolutional filter brings some invariance to small translations of the input signal

Convolutional features

Pooled feature (max or mean operator)

Page 158: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Convolutional nets

Apprentissage Statistique - P. Gallinari158

ConvNet architecture (Y. LeCun since 1988) Deployed e.g. at Bell Labs in 1989-90 Character recognition Convolution: non linear embedding in high dimension Pooling: average, max

Page 159: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari159

In Convnet The first hidden layer consists in 64 different convolution kernels over the initial

input, resulting in 64 different mapping of the input The second hidden layer is a sub-sampling layer with 1 pooling tranformation is

applied to each matrix representation of the first hidden layer etc Last layer is a classification layer

Page 160: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Convolutional nets - visualization

Apprentissage Statistique - P. Gallinari160

Hand writing recognition (Y. LeCun Bell labs 1989)

Page 161: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Convolutional nets (Krizhevsky et al. 2012)

Apprentissage Statistique - P. Gallinari161

A landmark in object recognition Imagenet competition

Large ScaleVisual Recognition Challenge

1000 categories, 1.5 Million labeled training samples

Method: large convolutional net

650K neurons, 630M synapses, 60M parameters

Trained with backprop on GPU

Page 162: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Convolutional nets (Krizhevsky et al. 2012)

Apprentissage Statistique - P. Gallinari162

Details of learned weights

Labels True label under the image

Predicted label probability for

the 5 most probable labels

Page 163: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Learning word vectors (Collobert et al. JMLR 2011)

Apprentissage Statistique - P. Gallinari163

Page 164: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Learning word vector representations(Mikolov et al. 2013a, 2013b)

Apprentissage Statistique - P. Gallinari164

Goal Learn robust vector representation of words that can be used in different

Natural Language Processing or Information retrieval tasks Learn word representations in phrase contexts Learn using very large text corpora Learn efficient, low complexity transformations

Page 165: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Learning word vector representations(Mikolov et al. 2013a, 2013b)

Apprentissage Statistique - P. Gallinari165

CBOW model Task

Predict the midle word of a sequnce of words

Input and output words are encoded usinga 1 out of n coding The projection layer is linear followed by a sigmoid Word weight vectors in the projection layerare shared (all the weight vectors are the same) The output layer computes a hierarchical softmax

See later

This allows computing the output in

log instead of The context is typically 4 words before and 4 after

Page 166: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Learning word vector representations (Mikolov et al. 2013a, 2013b)

Apprentissage Statistique - P. Gallinari166

Skip Gram model Similar to the CBOW model, except that the context is predicted from the

central word instead of the reverse As before, words are encoded using a 1 out of n code The output is computed using a hierarchical softmax classifier Output words are sampled less frequently if they arefar from the input word

i.e. if the context is C = 5 words each side, one selects ∈ 1;and use R words for the output context

Page 167: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Learning word vector representations (Mikolov et al. 2013a, 2013b)

Apprentissage Statistique - P. Gallinari167

Skip gram model Loss average log probability

∑ ∑ log |,

Where T is the number of words in the whole sequence used for training (roughlynumber of words in the corpus) and c is the context size

.

∑ .

Where is the learned representation of the w vector (the hidden layer), .is a dot product and V is the vocabulary size

Note that computing this softmax function is impractical since it is proportional to the size of the vocabulary

In practice, this can be reduced to a complexity proportional to log using abinarytree structure for computing the softmax Other alternatives are possible to compute the softmax in a reasonable time

Page 168: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Learning word vector representations(Mikolov et al. 2013a, 2013b)

Apprentissage Statistique - P. Gallinari168

Properties « analogical reasoning » This model learns analogical relationships between terms in the representation

space i.e. term pairs that share similar relations are share a similar geometric transformation

in the representation space

Example for the relation « capital of »

In the vector space Paris – France + Italy = Rome At least approximatively i.e. Rome is the nearest vector toParis – France + Italy

Page 169: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Learning word vector representations(Mikolov et al. 2013a, 2013b)

Apprentissage Statistique - P. Gallinari169

Paris – France + Italy = Rome

Page 170: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Image labeling at GoogleDeViSE: A Deep Visual-Semantic Embedding Model (Frome et al, NIPS 2013)

Apprentissage Statistique - P. Gallinari170

Goal Learn to label images

Approach Learn a language model from text

With the skip gram model of Mikolov et al. This models maps each word of a vocabulary onto a fixed vector space representation

This is called word representation Vectors are normalized to 1

Learn a visual model for image classification Similar to the convolutional model of Krizhevsky et al. 2012, trained with 1000 target classes The last layer of this network computes a representation of each image

This is called image representation Visual-semantic embedding

The language model is used to map the label terms onto the fixed word vector space representation A mapping is learned from the visual representation to the target words, word representation

This is a linear mapping with a ranking criterion This is called transformation mapping

Test time An image is

mapped onto its image representation This image representation is then mapped via the transformation mapping A nearest neighbor search produces a ranked list of potential labels

Page 171: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Image labeling at GoogleDeViSE: A Deep Visual-Semantic Embedding Model (Frome et al, NIPS 2013)

Apprentissage Statistique - P. Gallinari171

(image from Frome et al, NIPS 2013)

Page 172: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Image labeling at GoogleDeViSE: A Deep Visual-Semantic Embedding Model (Frome et al, NIPS 2013)

Apprentissage Statistique - P. Gallinari172

Loss function Ranking criterion ,

∑ max 0, Where

is the row vector of the text label representation (normalized to unit norm) is the matrix of the linear transformation is the column vector of the image representation is the row vector of another term representation (another text label also normalized to

unit norm) is a dot product (similarity) between and

This loss function was more efficient than an loss in the experiments

Training algorithm Stochastic gradient descent

Intersting properties Generalization to images with new labels (0 shot learning)

Page 173: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Image labeling at GoogleDeViSE: A Deep Visual-Semantic Embedding Model (Frome et al, NIPS 2013)

Apprentissage Statistique - P. Gallinari173

Page 174: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Modeling relational data (Bordes et al. 2013)

Apprentissage Statistique - P. Gallinari174

Objective Learn triplets (Subject, Predicate, Object) from multi-relational data Examples

Knowledge bases (S, P, O) = (Obama, president of, USA) e.g. Freebase 1.2 billion triplets, 80 million entities, thousands of relations

Social networks (A, friend of, B)

Infer new relations (S, P, ?) infer all objects in relation p with s

(S, ?, O) infer all relations between s and o

Any other inference task on the triplets

Page 175: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Modeling relational data (Bordes et al. 2013)

Apprentissage Statistique - P. Gallinari175

Method Learn representations for all occurrences of S, P and O so that (S, P, ?) and (S, ?,

O) questions can be answered Use the observations made in Word2Vec

When learning word representations from word sequences, some relations emerge as translations between s and o

Here the model will force the learning of translations in the representation space

Let , , ∈ the representations to be learned for S, P, O One wants if (S, P, O) holds

Representations are learned by optimizing a loss function representing this goal

Page 176: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Modeling relational data (Bordes et al. 2013)

Apprentissage Statistique - P. Gallinari176

The loss function is a margin based ranking function

∑ ∑ max 0, , , ,, , , , ,, , ∈

Where , is a disimilarity measure (e.g. distance)

, , is a corrupted version of , , , where either S has been replaced by a randomsubject S’ from the knowledge base or O has been replaced by O’

Margin is a positive scalar

This loss is a ranking based criterion i.e. it forces , , ,

Training It amounts at learning the representations , , by optimizing the loss Optimization is performed by stochastic gradient With the constraint 1

Page 177: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Modeling relational data (Bordes et al. 2013)

Apprentissage Statistique - P. Gallinari177

Examples (from Bordes et al. 2013)

Page 178: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Recursive neural networks (Socher et al. 2013)

Apprentissage Statistique - P. Gallinari178

Page 179: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari179

Exemple bengio slide Canadian AI 2014 Layer wise was an idea from 2006. Now possible to learn without

pre-training better intitilazation and alternative non linearities (e.g. rectifier)

Compositionality Recursive NNs à donner en exemple socher Autres papiers ? Distributed representations : mutually exclusice features (disantangle)

Exemples Collobert example Bordes S. bengio NIPS 2013, S. Bengio, Weston, Usunier

Sparse representations Dropout

Page 180: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Recurrent networks

Apprentissage Statistique - P. Gallinari180

Page 181: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari181

Recurrent networks

Dynamics time limited

Stop the dynamic after a # time steps unlimited

Wait for convergence: stable state or limit cycle

Input x : x(t0), x(t) = 0, t t0

x(t) = x(t0), t x(t) : sequence

Supervision Defined in the time x units space {1,...T} x {units}

e.g. at each step, at some prespecified stpes x units, at the end of the sequence, …

Recurrent neural networks are dynamic, non linear and continuousstate models

x(t)

di(t)

dj(t)

Page 182: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari182

Two types of formulation

Input – output State models

State models include the input-output formulation as a special case

Algorithms Deux main families:

Local recurrences Global recurrences

))(()( txfty

c t f c t x ty t g c t( ) ( ( ), ( ))( ) ( ( ))

1 1

Page 183: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Local recurrences (1)

Apprentissage Statistique - P. Gallinari183

Fixed recurrent connexions Probably the simplest architecture Recurrent connections are fixed by hand Only the forward connections are learned like in classical back propagation

Can be used in two modes x fixed sequence generation

E.g. x is the first term of a sequence to be generated by the network x sequence 1 ,… , classification

y

xc

1

))(),(()())(),((1)(

txtcgtytxtcftc

Page 184: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Local recurrences (2)

Apprentissage Statistique - P. Gallinari184

Here the local connections are learned The figure illustrates the simple case of self connections in the hidden layer (i.e.

the connection matrix is diagonal) Extensions

Several time delays (1, 2, …) Non diagonal recurrent matrix

e.g. if delay = 1, the hidden state at time t is: 1 ∑

Where is the state of hiden cell i

Training: back-propagation for sequences Loss:

Where t are the supervision steps and 1is t is a supervision step and 0 otherwise

y

x

t-1

t-2

Tt pi

iit tdtyQ

1..

2)()(

Page 185: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari185

Properties: Forgeting behavior: gradient vanishing:

Can only memorise short term dependencies

Can learn fixed size sequences up to the desired precision For unknown size sequences, there exists several limitations, e.g. cannot count the number of

occurrences in a sequence of unknown length

qj

iqtx

tx0

)()(

Page 186: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Global recurrences

Apprentissage Statistique - P. Gallinari186

Training Targets are provided at specific steps

For sequences of limited size Network unfolding Algorithm

Back propagation through time

For general sequences Algorithm is n

x01 x02

j

ijiji txtxwftx ))()((1)( 0

Dynamics

w12

t = 1

t = 3

t = 2

w11

w11 w22

w22

w21

w12w21

Unfolded NN:note that weights are shared

Page 187: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari187

Example : trajectory learning(Pearlmutter, 1995, IEEE Trans. on Neural Networks – nice review paper on RNN)

Globally recurrent net: 2 output units

Page 188: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Example : trajectory learning(Pearlmutter, 1995, IEEE Trans. on Neural Networks)

Apprentissage Statistique - P. Gallinari188

Recurrent net with 2 input units (sin q, cos q), 30 hidden units and 2 output units (x,y) :

Goal: learn a trajectory that depends on the inputs

0.50.5

/16/16

0.4tt

yx

cossin

cossinsincos

Page 189: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Recurrent neural networks with memory

Apprentissage Statistique - P. Gallinari189

Several attempts in order to limit or bypass the vanishing gradient problem

Here we present two models based on the same idea Add a memory to the recurrent cell, that enable to remember past states Add a possibility to forget the past of the sequence during its processing

Allows to model several successive sub-sequences as independent sequences

Page 190: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Gated recurrent unit – GRU (Cho et al. 2014)

Apprentissage Statistique - P. Gallinari190

Let us start with a locally connected recurrent net with recurrent units on the hiddenlayer

The gated recurrent unit has been proposed to capture dependencies at different time scales

The forward computation for a gated recurrent unit is governed by the followingequations (explained on the next slide):

1 h

tanh ⨀

In these equations Bold characters ( , ) denote vectors is the value of hidden cell j at time t ⨀ is the elementwise multiplication

WU

Page 191: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Gated recurrent unit (Cho et al. 2014)

Apprentissage Statistique - P. Gallinari191

The output of cell j is a weighted sum of the cell output at time t-1 and a new value of the cell h 1 h z is a gating function

If 0 is a simple copy of

If 1 it takes the new value h w.r.t the classical recurrent unit formulation, this new form allows us to

remember the value of the hidden cell at a given time in the past and reducesthe vanishing gradient phenomenon

The gating function is a function of the current input at time t and the past value of the hidden cell

The new value is a classical recurrent unit where the values at time t-1 are gated by a reset unit tanh ⨀

The reset unit allows us to forget the previous hidden state and to start again a new modeling of the sequence This is similar to a new state in a HMM (but it is soft)

h h’r

z1-z

⨂ ⨂

h

Page 192: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Gated recurrent unit (Cho et al. 2014)

Apprentissage Statistique - P. Gallinari192

There are two main novelties in this unit The z gating function and the + form of the cell value which acts for reducing

the vanishing gradient effect The r gating function which acts for forgeting the previous state and starting

again a new subsequence modeling with no memory

Each unit adapts its specific parameters, i.e. each may adapt its owntime scale and memory size

Training is performed using some adaptation of backpropagation for recurrent nets All the functions – unit states and gating functions are learned from the data

Page 193: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Long short term memory - LSTM

Apprentissage Statistique - P. Gallinari193

This was initially proposed in 1997 (Hochreiter et al.) and revisedlatter.

State of the art on several sequence prediction problems Speech, handwriting recognition, translation Used in conjontions with other models e.g. HMMs or in standalone recurrent

neural networks The presentation here is based on (Graves 2012)

Page 194: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Long short term memory

Apprentissage Statistique - P. Gallinari194

In the LSTM, there are 3 gating functions i: input gating o: output gating f: forget gating

Difference with the gated recurrent cell Similarities

Both use an additive form for computing the hidden cell state (c) here. This additive component reduces the vanishing gradient effect and allows us to keep

in memory past state values.

Both use a reset (called here forget (f)) gate The reset permits to start from a new « state » a subsequence prediction

Differences No output gating in the GRU

Reset does not play exactly the same role

c c’

o

if

⨂ ⨂

h

Page 195: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Long short term memory

Apprentissage Statistique - P. Gallinari195

For the forward pass, the different activations are computed as follows and the this order

tanh tanh

c c’

o

if

⨂ ⨂

h

Page 196: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Translation

Apprentissage Statistique - P. Gallinari196

NN have been used for a long time in translation systems (as an additional component, e.g. for reranking or as language model)

Recently translation systems have been proposed that are based on recurrent neural networks with GRU or LSTM units. Sutskever et al. 2014, Cho et al. 2014

General principle Sentence to sentence translation Use an encoder-decoder architecture Encoding is performed using a RNN on the input sentence (e.g. english) This transforms a variable length sequence into a fixed size vector which

encodes the whole sentence Starting with this encoding, another RNN generates the translated sentence (e.g.

French)

Page 197: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Translation

Apprentissage Statistique - P. Gallinari197

The encoder – decoder architecture

This is a sentence in English

Ceci est une phrase en Français

v: fixed size representation of the input sentence

Page 198: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Translation

Apprentissage Statistique - P. Gallinari198

Let , … , be an input sentence , … , be an output sentence Note that T and T’ might be different and that the word order in the two sentences is also

generally different

Objective Learn , … , | , … , ) Encoder

Reads each symbol of the input sentence sequentially using a RNN After each symbol the state of the RNN is changed according to , After reading the sentence, the final state is

Decoder Generates the output sequence by predicting the next symbol given the hidden state ,

and the vector : , , , … , , , ,

Training max ∑ log |

Page 199: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Translation

Apprentissage Statistique - P. Gallinari199

Architecture RNN with 1000 hidden cells Word embeddings of dimension between 100 and 1000 Softmax at the output for computing the word probabilities Of the order of 100 M parameters

Page 200: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Neural image caption generator (Vinyals et al. 2015)

Apprentissage Statistique - P. Gallinari200

Objective Learn a textual description of an image

i.e. using an image as input, generate a sentence that describes the objects and theirrelation!

Model Inspired by a translation approach but the input is an image

Use a RNN to generate the textual description, word by word, provided a learneddescription of an image via a deep CNN

Page 201: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Neural image caption generator (Vinyals et al. 2015)

Apprentissage Statistique - P. Gallinari201

Loss criterion max∑ log | ;,

Where ( , ) is an associated couple (Image, Sentence)

log | ; ∑ log , , … , , , … , is modeled with a RNN with , … , encoded into the

hidden state of the RNN Here , is modelled using a RNN with LSTM For encoding the image, a CNN is used

Page 202: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Neural image caption generator (Vinyals et al. 2015)

Apprentissage Statistique - P. Gallinari202

Page 203: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage non supervisé

Algorithme EM et mélange de densitésSpectral clustering

Non Negative Matrix Factorization

Page 204: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Applications

Apprentissage Statistique - P. Gallinari204

analyse des données quand il n'y a pas de connaissance sur la classe. e.g. pas d'étiquetage des données (problème nouveau)

trop de données ou étiquetage trop compliqué e.g. traces utilisateur (web), documents web, parole, etc

réduction de la quantité d'information e.g. quantification

découverte de régularités sur les données ou de similarités.

Page 205: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage non supervisé

Algorithme Espérance Maximisation (EM)Application aux mélanges de densités

Page 206: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Algorithme E. M. (Espérance Maximisation)

Apprentissage Statistique - P. Gallinari206

On dispose de données D = {xi}i = 1..N

On n’a pas d’étiquette di

d’un modèle génératif, de paramètres W : FW Le modèle « explique » la génération des données

On veut trouver les paramètres du modèle qui expliquent au mieux lagénération des données

On se donne un critère Ici on considère la vraisemblance des données qui est le critère le plus

fréquent P(D| W) = P(x1, …, xN| W)

D’autres critères sont également couramment utilisés On va essayer de déterminer les paramètres W de façon à maximiser la

vraisemblance

Page 207: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Exemple

On recueille des données sur deux populations e.g. taille d’individus D = {xi}i = 1..N

Hypothèse les données de chaque population sont gaussiennes Elles ont la même variance 2

Problème estimer les i et les à partir des données Si les di sont connus, i.e. D = {(xi, di}i = 1..N la solution est simple

On a deux population séparées (2 classes) C1, C2

La maximisation de la vraisemblance donne l’estimateur classique de la moyenne

Difficulté : les di sont inconnus

),(),,( 22

21 IdNIdN

Apprentissage Statistique - P. Gallinari207

ji Cx

i

jj x

C1

Page 208: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Cas où l’appartenance est connue

Apprentissage Statistique - P. Gallinari208

Vraisemblance ∏ |∈ ∏ |∈

En pratique on maximise la log-vraisemblance log ∑ ∑ ∈∈

Cas des gaussiennes

exp

0 ⇔| |

∑ ∈

Page 209: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Cas où la probabilité d’appartenance est connue

Apprentissage Statistique - P. Gallinari209

On connait | ,k 1,2

Log-vraisemblance log ∑ log Cas des gaussiennes

0 ⇔∑ .

∑ |

Rq : si on ne connait pas les | ,k 1,2 leséquationsformentunsystèmenonlinéairecouplé,insoluble.

Page 210: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Variables cachées (ou latentes)

Apprentissage Statistique - P. Gallinari210

On postule l’existence de variables cachées h responsables de la génération des données

À chaque xi, on associe sa classe cachée hi

H = {hi}I = 1..N

l’existence d’une fonction densité jointe sur les données observées et cachées p(x, h)

P(D, H| W) sera appelé vraisemblance complète des données pour le modèle W.

Remarque Les variables h sont inconnues et sont considérées comme des variables

aléatoires P(D, H| W) sera elle même une variable aléatoire

Page 211: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Algorithme EM On veut maximiser P(D/W)à partir de l'observation des données visibles

Problème

la maximisation directe de P(D/W) ne conduit pas à des formules calculatoires (algorithme)

Solution : on maximise de façon itérative une fonction auxiliaire Q

L’espérance de la vraisemblance des données complètes connaissant le modèle courant

L’espérance est calculée par rapport à la distribution des variables cachées h

Le modèle courant à l’étape t est noté W(t)

Remarque : dans cette expression

D et W(t) sont des constantes

h est une variable aléatoire de densité p(h ; x, W(t))

W sont les paramètres du modèle que l’on veut estimer

H

ttH

t WHDpWDHpWDWHDpEWWQ )/,(log),;(,; )/,(log)/( )()()(

Apprentissage Statistique - P. Gallinari211

Page 212: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Algorithme EM

Apprentissage Statistique - P. Gallinari212

L’algorithme converge vers un maximum local de la fonction Q et de P(D/W)

Initialiser W = W(0)

1. Etape E : EspéranceOn calculeOn en déduitL'espérance est calculée par rapport à la distribution de H

2. Etape M : MaximisationEtant donnée la distribution courante sur H, trouver les paramètres quimaximisent Q

),;( )(tWDHp

);( )(tWWQ

)(1)( ,);/,(logmaxarg t

W

t WDWHDpEW

Page 213: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari213

Remarques Lors de l'étape E, on estime la distribution de H, à partir

des valeurs courantes des paramètres W(t). Au lieu d'essayer de maximiser directement, on utilise la

fonction auxiliaire Q. On peut montrer la convergence de l'algorithme par :

L'algorithme est utilisé pour les algorithmes non supervisés, semi - supervisés les données manquantes ou les composantes manquantes dans les données les HMM ...

),;( )(tWDHp

)/( WDp

);();();();( 11 tttttt WDpWDpWWQWWQ

Page 214: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Exemple

Apprentissage Statistique - P. Gallinari214

Mélange de densités - Cas de deux classe gaussiennes, connu But (MV) : trouver On considère , les hi sont les données

cachées Algorithme

Initialisation itérer

Etape E

Etape M

NiixD ..1)( ),/(maxarg, 2121 Dp

Niii hxHD ..1),(

calculer i = 1..N, j = 1,2)/( ii xjhp )],,;([),,;,,( 212121

tttttt HDPEQ

Trouver les μ1, μ2 qui maximisent Qcalculer

Ni

Nitj i

ii

xjhp

xxjhp

..1

..1)1(

)/(

)/(

(0)2 ,)0(

1

Page 215: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari215

Remarques Etape E : calcul de la responsabilité de chaque gaussienne pour chaque point

Etape M : chaque centre est défini comme le centre de toutes les données,chacune étant pondérée par cette responsabilité

Cas limite : = 0 : algorithme des k-moyennes

k

iii

iiiii

khxpkhpjhxpjhpxjhp

)/()()/()()/(

Page 216: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Mélange de densités – cas gaussien

Apprentissage Statistique - P. Gallinari216

On suppose que le modèle génératif des données est un mélange de densités gaussiennes On fixe a priori le nombre de composantes du mélange à k on suppose que les données x sont unidimensionnelles

Paramètres Coefficients du mélange p(l| x), moyennes et écarts types

k

llxplpxp

1)/()()( 2

2

2)(

2/12 )2(1)/( l

lx

l

elxp

kllllpW

1..,),(

Page 217: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Vraisemblance

Vraisemblance complète variables cachées : hi classe de xi

N

i

k

l

i WlxpWlpWDp1 1

),/()/()/(

)),/()/((

)),/()/(()/,(

1 1

1

N

i

ik

l lh

N

i

iii

WlxpWlp

WhxpWhpWHDp

i log

loglog

Apprentissage Statistique - P. Gallinari217

Page 218: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Mélange de densité – Etapes E et M

Apprentissage Statistique - P. Gallinari218

Etape E

Etape M

),/()/(log),/(

),/()/,(log...)],(log[)/(

1 1

)(

1 1 1

)(,/

)(

1)(

WlxpWlpWxlp

WxhpWHDpWHDpEWWQ

iN

i

k

l

ti

k

h

k

h

N

i

tiiWXH

t

Nt

kl

tti

ttit

i Wlp(hWlhxp

Wjp(hWjhxpWxjhp

1..

)()(

)()()(

)).,/(

)),/(),/(

))1)/(((1)/( contrainte sous

)(

11

k

l

k

l

WlpQMinWlp

QMin

Page 219: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Mélange de densités – Reestimation dans l’étape M

Apprentissage Statistique - P. Gallinari219

i

titi

tii

tj

iti

tj

i

tii

iti

tj

WxjpN

jp

Wxjp

xWxjp

n

Wxjp

xWxjp

),/(1)(

),/(

),/(1

),/(

),/(

)()1(

)(

2)1()(2)1(

)(

)(

)1(

Page 220: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage non supervisé

Mélange de densitésApprentissage par échantillonnage de Gibbs

Page 221: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Les méthodes MCMCMarkov Chain Monte Carlo

Apprentissage Statistique - P. Gallinari221

Méthodes de calcul intensif basées sur la simulation pour Echantillonnage de variables aléatoires

{x(t)}t=1..T qui suivent une certaine distribution p(x)

Calcul de l’espérance de fonctions suivant cette distribution

E[f(x)] sera estimé par 1/T . Σt=1..Tf(x(t))

e.g. moyenne, marginales, …

Maximisation de fonctions Argmaxxp(x)

Page 222: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Echantillonneur de Gibbs On veut estimer une densité p(x) avec x = (x1,..,xn) Hyp

On connait les lois conditionnelles p(xi| x1,.., xi -1, xi+1,..., xn) = p(xi| x - i)

Algorithme Initialiser {xi, i = 1..n} Pour t = 1 …T faire

)(~nner Echantillo

........

)(~nner Echantillo

1

111

1

tnn

tn

tt

xxpx

xxpx

Apprentissage Statistique - P. Gallinari222

Page 223: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari223

Propriétés Sous certaines conditions de régularité, la procédure converge vers la

distribution cible p(x) Les échantillons résultants sont des échantillons de la loi jointe p(x)

On n’a pas besoin de connaitre la forme analytique des p(xi| x - i) mais uniquement de pouvoir échantillonner à partir de ces distributions Mais la forme analytique permet d’avoir de meilleurs estimés

Avant de retenir les points échantillons, on autorise souvent une période de “burn-in” pendant laquelle on fait simplement tourner l’algorithme “à vide”

Gibbs facile à implémenter, adapté aux modèles hierarchiques (cf LDA)

Page 224: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Cas du mélange de deux lois gaussiennes Modèle

On va considérer un modèle augmenté en ajoutant une variable cachée h Les données complètes sont les (xi, hi)

Les paramètres à estimer sont :

On va utiliser Gibbs en échantillonnant sur les densités conditionnelles Pour simplifier on suppose dans l’example que les proportions p(l) et les

variances σ sont fixées, on estime juste les moyennes μ1 et μ2

Pour cela, on va échantillonner suivant la distribution jointe (h(t), μ1(t), μ2

(t))

2

1)/()()(

llxplpxp

2..1,),( llllpW

Apprentissage Statistique - P. Gallinari224

Page 225: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Echantillonneur de Gibbs pour le modèle de mélange de deux gaussiennes

Apprentissage Statistique - P. Gallinari225

2,1),,ˆ(~générer 2.

2,1,)1(

).1(ˆ

calculer

2,1,),(),(

),()

selon 1,0générer 1.

1Pour 1...T Répéter t

, initiales valeursdesChoisir

j(t)j

1

)(

1

)(

j

2)1(

2)1(

21)1(

1)1(

1

)1()1(

)(

)0(2

)0(1

jN

jh

xh

jxppxpp

xppjp(h

h

...N i

j

N

i

ti

N

ii

ti

ti

tti

tj

tji

tj

i

ti

Page 226: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Lien avec l’algorithme EM

Apprentissage Statistique - P. Gallinari226

Les étapes pour cet exemple sont les mêmes que avec EM Différence

Au lieu de maximiser la vraisemblance, aux étapes 1 et 2, on échantillonne Etape 1 : on simule les variables cachées h au lieu de calculer E(h|W, D) Etape 2 : on simule à partir de p(μ1, μ2|h, D) au lieu de calculer le max. vraisemblance

p(μ1, μ2| D) dans EM

Page 227: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage non supervisé

Spectral Clustering

Apprentissage Statistique - P. Gallinari227

Page 228: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Spectral Clustering (after Von Luxburg 2007)

Apprentissage Statistique - P. Gallinari228

Intuition x1, …, xn data points, wij similarity between xi and xj

G = (V, E) graph vertex vi corresponds to data point xi

Edges are weighted by wij

Clustering amounts at finding a graph partition such that Edges between clusters have low weights

Edges among points inside a cluster have high values

Page 229: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari229

Graphs notations G = (V, E) undirected graph

V = {v1, …, vn)

Edges are weighted, W = (wij)I, j = 1…n , wij ≥ 0 is the weight matrix

D : diagonal matrix with ∑

Page 230: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari230

Building similarity graphs from data points Different ways to build a similarity graph Locally connected graphs: k-nearest neighbor graphs

Two vertices are connected if one of them is among the k-nearest neighbor of the other

Or two vertices are connected if both are in the k-neighborhood of the other

Edges are then weighted using the similarity of the vertices

Fully connected graphs

exp /2 )

Page 231: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari231

Graph Laplacians Unnormalized graph Laplacian

Normalized graph Laplacians

I symmetric

interpretation : random walk on the graph

Page 232: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari232

Properties of the unnormalized graph Laplacian L satisfies:

∀ ∈ , ∑ ,

L is symmetric, positive semi-definite

The smallest eigenvalue of L is 0, the corresponding eigenvector is 1 (vector with n 1)

L has n non negative eigenvalues 0 …

Page 233: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari233

Properties of the normalized graph Laplacians

∀ ∈ , ∑ ,

Lsym and Lrw are positive semi-definite and have n non negative eigenvalues 0 …

is an eigenvalue of Lrw with eigenvector u iff is an eigenvalue of Lsym with eigenvector D1/2u

Page 234: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Unnormalized spectral clustering

Apprentissage Statistique - P. Gallinari234

Idée Projeter les points x ∈ , i 1…n, dans un espace de dimension k dans

lequel le clustering se fait facilement

Page 235: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Unnormalized spectral clustering

Apprentissage Statistique - P. Gallinari235

Idea Project data points x ∈ , i 1…n, in a smaller dimensional space, say of

dimension k where clustering is performed

Input: n points x1, …, xn, similarity matrix S Output: clusters

Construct similarity graph and corresponding weight matrix W Compute unnormalized Laplacian L Compute first eigenvectors of L (corresponding to smallest eigenvalues): u1, …, uk

U: n x k matrix with columns u1, …, uk

For i = 1…n, ∈ i-th row of U Cluster yi, i = 1…n with k-means into clusters C1, …, Ck

k clusters in the initial space: C’1, …, C’k / C’i = {xj / yj Ci}

Note: Similar algorithms with normalized Laplacians

Page 236: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage non supervisé

Non Negative Matrix Factorization

Apprentissage Statistique - P. Gallinari236

Page 237: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Matrix Factorization

Apprentissage Statistique - P. Gallinari237

Idea Project data vectors in a latent space of dimension k < m size of the original

space Axis in this latent space represent a new basis for data representation Each original data vector will be approximated as a linear combination of k basis

vectors in this new space Data are assigned to the nearest axis This provide a clustering of the data

Page 238: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Matrix factorization

Apprentissage Statistique - P. Gallinari238

X = {x.1,…, x.n}, ∈ X m x n matrix with columns the x.i s Low rank approximation of X

Find factors U, V, / With U an m x k matrix, U a k x n matrix, k < m, n

x

m x n m x k k x n

Many differentdecompositions e.g. SingularValue Decomposition, Non Negative Matrix Factorization, Tri factorization, etc

X U V

Page 239: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

MARAMI 2013 - Learning representations for social networks

239

Applications Recommendation (User x Item matrix)

Matrix completion

Link prediction (Adjacency matrix) …

Page 240: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

MARAMI 2013 - Learning representations for social networks

240

. ∑ .

Columns ofU,u.j arebasisvectors,the arethecoefficientof . inthisbasis

X V

x.j v.ju.1u.2u.3

Original data Basis vectorsDictionnary

Representation

x

v.j

u.1

u.2

u.3

Page 241: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

MARAMI 2013 - Learning representations for social networks

241

Interpretation If X is a User x Item matrix

Users and items are represented in a common representation space of size k Their interaction is measured by a dot product in this space

x.jv.j

ui.

Original data User Representation

Item Representation

xUsers

Items

Page 242: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

MARAMI 2013 - Learning representations for social networks

242

Interpretation If X is a directed graph adjacency or weight matrix

x.jv.j

ui.

Original data Sender Representation

ReceiverRepresentation

xNodes

Nodes

Page 243: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

MARAMI 2013 - Learning representations for social networks

243

Loss function - example Minimize ,

constraints on U, V: , e.g. Positivity (NMF)

Sparsity of representations, e.g. , group sparsity, …

Overcomplete dictionary U: k > m

Symmetry, e.g. trifactorisation

Bias on U and V e.g. biases of users (low scores) or item (popularity) for recommendation

Multiple graphs

Any a priori knowledge on U and V

Page 244: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Non Negative Matrix Factorization

Apprentissage Statistique - P. Gallinari244

Loss function Solve

, Underconstraints , 0

i.e.thefactors areconstrained tobe nonnegative Convex loss function inUandinV,butnotinboth UandV

Page 245: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari245

Algorithm Constrained optimization problem Can be solved by a Lagrangian formulation

Iterative multiplicative algorithm (Xu et al. 2003)

U, V initialized at random values Iterate until convergence

Or by projected gradient formulations The solution U, V is not unique, if U, V is solution, then UD, D-1V for D diagonal

positive is also solution

Page 246: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari246

Using NMF for Clustering Normalize U as a column stochastic matrix (each column vector is of norm 1)

←∑

← ∑

Under the constraint “U normalized” the solution U, V is unique Associate xi to cluster j if

Page 247: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Apprentissage Statistique - P. Gallinari247

Note many different versions and extensions of NMF Different loss functions

e.g. different constraints on the decomposition

Different algorithms

Applications Clustering Recommendation Link prediction Etc

Specific forms of NMF can be shown equivalent to PLSA Spectral clustering

Page 248: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Illustration (Lee & Seung 1999)

Apprentissage Statistique - P. Gallinari248

Basis images for

NMF

Vector Quantization

Principal Component Analysis

Page 249: Apprentissage Statistique - Laboratoire d'informatique de Paris 6gallinar/gallinari/uploads/Teaching/... · 2015-02-03 · Plan du cours 2 Apprentissage Statistique - P. Gallinari

Some useful links

Apprentissage Statistique - P. Gallinari249

Books Closest to this course

Cornuéjols A and Miclet L.: Apprentissage Artificiel. Concepts et algorithmes (2nd ed.withrevisions and additions - 2006 Eyrolles,

Christopher M. Bishop, Pattern Recognition and Machine Learning, Springer (2006) Most useful

Hastie T, Tibshirani R, and Friedman J, (2009). The Elements of Statistical Learning (2nd edition), Springer-Verlag.

pdf version at http://statweb.stanford.edu/~tibs/ElemStatLearn/ David Barber, 2012, Bayesian Reasoning and Machine Learning, Cambridge Univ. Press.

Software General

Weka 3: Data Mining Software in Java http://www.cs.waikato.ac.nz/ml/weka/

SVM http://www.csie.ntu.edu.tw/~cjlin/libsvm/

http://svmlight.joachims.org/ Neural networks

http://www.torch.ch/ Test sets

UCI machine learning repository …..