Skip to content

Commit cd94a5c

Browse files
committed
réseaux de neurons + todos
1 parent b9ae7af commit cd94a5c

File tree

371 files changed

+15273
-22
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

371 files changed

+15273
-22
lines changed

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ README
4040

4141
.. image:: https://badge.waffle.io/sdpython/mlstatpy.png?label=ready&title=Ready
4242
:alt: Waffle
43-
:target: https://waffle.io/mlstatpy/pymyinstall
43+
:target: https://waffle.io/mlstatpy/mlstatpy
4444

4545

4646

_doc/sphinxdoc/source/c_ml/rn.rst

+10-9
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ l'`analyse en composantes principales <https://fr.wikipedia.org/wiki/Analyse_en_
1313
ou :ref:`ACP <nn-ACP>`
1414
sans oublier les méthodes d'estimation des paramètres qui les composent,
1515
à savoir optimisations du premier et second ordre
16-
(:ref:`nn-rn_optim_premier_ordre`) et :ref`nn-rn_optim_second_ordre`
16+
(:ref:`rn_optim_premier_ordre`) et :ref`rn_optim_second_ordre`
1717
ainsi qu'une méthode permettant de supprimer des coefficients inutiles
18-
:ref`nn-selection_connexion`.
18+
:ref`selection_connexion`.
1919

20-
.. contents:: .
21-
:depth: 2
20+
.. toctree::
21+
:maxdepth: 2
2222

23-
.. include:: rn_1_def.txt
24-
.. include:: rn_2_reg.txt
25-
.. include:: rn_3_clas.txt
26-
.. include:: rn_4_reg2.txt
27-
.. include:: rn_biblio.txt
23+
rn_1_def
24+
rn_2_reg
25+
rn_3_clas
26+
rn_4_densite
27+
rn_5_newton
28+
rn_biblio
2829

2930

3031

_doc/sphinxdoc/source/c_ml/rn_4_reg2.txt renamed to _doc/sphinxdoc/source/c_ml/rn_4_densite.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ compacts connexes par arcs et disjoints
385385
386386
387387
388-
**Démontration du théorème de :ref:`densité des réseaux de neurones <theoreme_densite>`**
388+
**Démontration du théorème de** :ref:`densité des réseaux de neurones <theoreme_densite>`
389389

390390
*Partie 1*
391391

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
2+
3+
4+
5+
Méthode d'optimisation de Newton
6+
================================
7+
8+
Lorsqu'un problème d'optimisation n'est pas soluble de manière déterministe,
9+
il existe des algorithmes permettant de trouver une solution approchée
10+
à condition toutefois que la fonction à maximiser ou minimiser soit dérivable,
11+
ce qui est le cas des réseaux de neurones. Plusieurs variantes seront proposées
12+
regroupées sous le terme de descente de gradient.
13+
14+
15+
16+
Algorithme et convergence
17+
+++++++++++++++++++++++++
18+
19+
20+
Soit :math:`g : \R \dans \R` une fonction dérivable dont il faut trouver
21+
:math:`\overset{*}{x} = \underset{x \in \R}{\arg \min} \; g\pa{x}`,
22+
le schéma suivant illustre la méthode de descente de gradient
23+
dans le cas où :math:`g \pa{x} = x^2`.
24+
25+
26+
.. image:: rnimg/rn_courbe.png
27+
28+
29+
On note :math:`x_{t}` l'abscisse à l'itération :math:`t`.
30+
On note :math:`\dfrac{\partial g\left( x_{t}\right) }{\partial x}` le
31+
gradient de :math:`g\left( x\right) =x^{2}`.
32+
L'abscisse à l'itération :math:`t+1` sera
33+
:math:`x_{t+1}=x_{t}-\varepsilon_{t}\left[ \dfrac{\partial g\left( x_{t}\right)}{\partial x}\right]`.
34+
:math:`\varepsilon_{t}` est le pas de gradient à l'itération :math:`t`.
35+
36+
On suppose maintenant que :math:`g` est une fonction dérivable
37+
:math:`g : \R^q \dans \R` dont il faut trouver le minimum, le théorème suivant démontre
38+
la convergence de l'algorithme de descente de gradient à condition
39+
que certaines hypothèses soient vérifiées. Une généralisation de ce théorème est présentée dans
40+
[Driancourt1996]_.
41+
42+
43+
.. mathdef::
44+
:title: convergence de la méthode de Newton [Bottou1991]_
45+
:tag: Théorème
46+
:lid: theoreme_convergence
47+
48+
49+
Soit une fonction continue :math:`g : W \in \R^M \dans \R`
50+
de classe :math:`C^{1}`.
51+
On suppose les hypothèses suivantes vérifiées :
52+
53+
* **H1** : :math:`\underset{W\in \R^q}{\arg\min} \;
54+
g\left( W\right) =\left\{ W^{\ast}\right\}`
55+
est un singleton
56+
* **H2** : :math:`\forall\varepsilon>0, \; \underset{\left| W-W^{\ast}\right|
57+
>\varepsilon}{\inf}\left[ \left( W-W^{\ast}\right) ^{\prime}.\nabla
58+
g\left( W\right) \right] >0`
59+
* **H3** : :math:`\exists\left( A,B\right) \in \R^2` tels que :math:`\forall W\in\R^p,\; \left\|
60+
\nabla g\left( W\right) \right\| ^{2}\leqslant A^{2}+B^{2}\left\| W-W^{\ast}\right\| ^{2}`
61+
* **H4** : la suite :math:`\left( \varepsilon_{t}\right)_{t\geqslant0}` vérifie,
62+
:math:`\forall t>0, \; \varepsilon_{t}\in \R_{+}^{\ast}`
63+
et :math:`\sum_{t\geqslant 0}\varepsilon_{t}=+\infty`,
64+
:math:`\sum_{t\geqslant 0}\varepsilon_{t}^{2}<+\infty`
65+
66+
Alors la suite :math:`\left( W_{t}\right) _{t\geqslant 0}` construite de la manière suivante
67+
:math:`W_{0} \in \R^M`, :math:`\forall t\geqslant0` :
68+
:math:`W_{t+1}=W_{t}-\varepsilon_{t}\,\nabla g\left( W_{t}\right)`
69+
vérifie :math:`\lim_{ t \dans+\infty}W_{t}=W^{\ast}`.
70+
71+
72+
73+
L'hypothèse **H1** implique que le minimum de la fonction :math:`g`
74+
est unique et l'hypothèse **H2** implique que le demi-espace défini par
75+
l'opposé du gradient contienne toujours le minimum de la fonction :math:`g`.
76+
L'hypothèse **H3** est vérifiée pour une fonction sigmoïde, elle l'est donc aussi pour toute somme finie
77+
de fonctions sigmoïdes que sont les réseaux de neurones à une couche cachée.
78+
79+
80+
81+
**Démonstration du théorème**
82+
83+
*Partie 1*
84+
85+
86+
Soit la suite :math:`u_{t}=\ln\left( 1+\varepsilon_{t}^{2}x^{2}\right)`
87+
avec :math:`x\in\R`, comme :math:`\sum_{t\geqslant 0} \varepsilon_{t}^{2} < +\infty, \;
88+
u_{t}\thicksim\varepsilon_{t}^{2}x^{2}`, on a :math:`\sum_{t\geqslant 0} u_{t} < +\infty`.
89+
90+
Par conséquent, si :math:`v_{t}=e^{u_{t}}` alors :math:`\prod_{t=1}^T v_{t}\overset{T \rightarrow \infty}{\longrightarrow}D \in \R`.
91+
92+
*Partie 2*
93+
94+
On pose :math:`h_{t}=\left\| W_{t}-W^{\ast}\right\| ^{2}`.
95+
Donc :
96+
97+
.. math::
98+
:nowrap:
99+
:label: equation_convergence_un
100+
101+
\begin{eqnarray}
102+
h_{t+1} -h_{t} &=&\left\| W_{t}-\varepsilon_{t}\,\nabla g\left( W_{t}\right) -W^{\ast }\right\|
103+
^{2}-\left\|W_{t}-W^{\ast}\right\| ^{2}
104+
\end{eqnarray}
105+
106+
Par conséquent :
107+
108+
.. math::
109+
110+
h_{t+1}-h_{t}=-2\varepsilon_{t}\underset{>0} {\underbrace{\left( W_{t}-W^{\ast}\right)
111+
^{\prime}\,\nabla g\left( W_{t}\right)
112+
}}+\varepsilon_{t}^{2}\,\left\| \,\nabla C\left( W_{t}\right) \right\|
113+
^{2}\leqslant\varepsilon_{t}^{2}\,\left\| \,\nabla g\left( W_{t}\right)
114+
\right\| ^{2}\leqslant\varepsilon_{t}^{2}\,\left( A^{2} +B^{2}h_{t}\right)
115+
116+
D'où :
117+
118+
.. math::
119+
120+
h_{t+1}-h_{t}\left( 1+\varepsilon_{t}^{2}B^{2}\right) \leqslant\varepsilon_{t}^{2}\,A^{2}
121+
122+
On pose :math:`\pi_{t}= \prod_{k=1}^t \left( 1+\varepsilon_{k}^{2}B^{2}\right) ^{-1}`
123+
alors en multipliant des deux côtés par :math:`\pi_{t+1}`, on obtient :
124+
125+
.. math::
126+
127+
\begin{array}{rcl}
128+
\pi_{t+1}h_{t+1}-\pi_{t}h_{t} &\leqslant& \varepsilon_{t}^{2}\,A^{2}\pi_{t+1}\\
129+
\text{d'où }\pi_{q+1}h_{q+1}-\pi_{p}h_{p} &\leqslant&
130+
\sum_{t=p}^q \varepsilon_{t}^{2}\,A^{2}\pi_{t+1} \leqslant
131+
\sum_{t=p}^{q} \varepsilon_{t}^{2} \, A^{2}\Pi \leqslant \sum_{t=p}^{q} \varepsilon_{t}^{2}\,A^{2}\Pi
132+
\underset{t \longrightarrow
133+
\infty}{\longrightarrow} 0
134+
\end{array}
135+
136+
Comme la série :math:`\sum_t \pa{\pi_{t+1}h_{t+1}-\pi_{t}h_{t}}` vérifie le critère de Cauchy, elle est convergente. Par conséquent :
137+
138+
.. math::
139+
140+
\underset{q\rightarrow\infty}{\lim}\pi_{q+1}h_{q+1}=0=\underset{q\rightarrow \infty}{\lim}\Pi h_{q+1}
141+
142+
D'où :math:`\underset{q\rightarrow\infty}{\lim}h_{q}=0`.
143+
144+
*Partie 3*
145+
146+
147+
La série :math:`\sum_t\pa{h_{t+1}-h_{t}}` est convergente car :math:`\Pi h_t \sim \pi_t h_t`.
148+
:math:`\sum_{t\geqslant0}\varepsilon_{t}^{2}\,\left\| \,\nabla g\left( W_{t}\right) \right\| ^{2}`
149+
l'est aussi (d'après **H3**).
150+
151+
D'après :eq:`equation_convergence_un`,
152+
la série :math:`\sum_{t\geqslant 0}\varepsilon_{t}\left( W_{t}-W^{\ast }\right) ^{\prime} \,
153+
\nabla g\left( W_{t}\right)` est donc convergente.
154+
Or d'après les hypothèses **H2**, **H4**, elle ne peut l'être que si :
155+
156+
.. math::
157+
:nowrap:
158+
159+
\begin{eqnarray}
160+
\underset{t\rightarrow\infty}{\lim}W_{t}&=&W^{\ast}
161+
\end{eqnarray}
162+
163+
164+
165+
Si ce théorème prouve la convergence
166+
de la méthode de Newton, il ne précise pas à quelle vitesse cette convergence
167+
s'effectue et celle-ci peut parfois être très lente. Plusieurs variantes
168+
ont été développées regroupées sous le terme de méthodes de quasi-Newton dans le but
169+
d'améliorer la vitesse de convergence (voir :ref:`rn_section_train_rn`).
170+
171+
Ce théorème peut être étendu dans le cas où la fonction :math:`g`
172+
n'a plus un seul minimum global mais plusieurs minima locaux ([Bottou1991]_),
173+
dans ce cas, la suite :math:`\pa{W_{t}}` converge vers un mimimum local.
174+
Dans le cas des réseaux de neurones, la fonction à optimiser est :
175+
176+
.. math::
177+
:nowrap:
178+
:label: equation_fonction_erreur_g
179+
180+
\begin{eqnarray}
181+
G\pa{W} &=& \sum_{i=1}^{N} e\pa {Y_{i}, \widehat{Y_{i}^W}} \\
182+
&=& \sum_{i=1}^{N} e\pa {Y_{i}, f \pa{W,X_{i}}}
183+
\end{eqnarray}
184+
185+
Dès que les fonctions de transfert ne sont pas linéaires,
186+
il existe une multitude de minima locaux, ce nombre croissant avec celui des coefficients.
187+
188+
189+
190+

_doc/sphinxdoc/source/c_ml/rn_biblio.txt renamed to _doc/sphinxdoc/source/c_ml/rn_biblio.rst

+12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11

22

3+
Bibliographie
4+
=============
5+
6+
.. [Bottou1991] Une approche théorique de l'apprentissage connexionniste, Application à la reconnaissance de la parole,
7+
Léon Bottou,
8+
*Thèse de l'Université de Paris Sud, Centre d'Orsay*.
9+
310
.. [Bishop1995] Neural networks for pattern recognition (1995),
411
C. M. Bishop, *Oxford University Press*
512
613
.. [Cybenko1989] Approximation by superpositions of a sigmoidal function (1989),
714
G. Cybenko, *Mathematics of Controls, Signals, and Systems*,
815
p 303-314
916
17+
.. [Driancourt1996] Optimisation par descente de gradient stochastique de systèmes modulaires
18+
combinant réseaux de neurones et programmation dynamique,
19+
Application à la reconnaissance de la parole (1996), X. Driancourt,
20+
*Thèse de l'Université de Paris Sud, Centre d'Orsay*.
21+
1022
.. [LeCun1985] Une procédure d'apprentissage pour réseaux à seuil asymétrique (1985),
1123
Yann Le Cun, *Cognita*, p 599-604
1224

_doc/sphinxdoc/source/conf.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
"pyquickhelper",
2121
"src")))
2222

23+
local_template = os.path.join(os.path.abspath(os.path.dirname(__file__)), "phdoc_templates")
24+
2325
from pyquickhelper.helpgen.default_conf import set_sphinx_variables
2426
set_sphinx_variables(__file__, "mlstatpy", "Xavier Dupré", 2016,
25-
sphtheme.__name__, [
26-
sphtheme.get_html_theme_path()], locals(),
27+
sphtheme.__name__, [sphtheme.get_html_theme_path()], locals(),
2728
extlinks=dict(
2829
issue=('https://github.com/sdpython/mlstatpy/issues/%s', 'issue')),
2930
title="Machine Learning, Statistiques et Programmation", book=True)
@@ -52,6 +53,7 @@
5253
\\newcommand{\\loi}[0]{{\\cal L}}
5354
\\newcommand{\\vecteurno}[2]{#1,\\dots,#2}
5455
\\newcommand{\\norm}[1]{\\left\\Vert#1\\right\\Vert}
56+
\\newcommand{\\dans}[0]{\\rightarrow}
5557
"""
5658

5759
imgmath_latex_preamble += custom_preamble

_doc/sphinxdoc/source/index.rst

+12-8
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,12 @@ Xavier Dupré
3737
:target: https://ci.appveyor.com/project/sdpython/mlstatpy
3838
:alt: Build Status Windows
3939

40-
.. image:: https://badge.fury.io/py/project_name.svg
41-
:target: http://badge.fury.io/py/project_name
40+
.. image:: https://badge.fury.io/py/mlstatpy.svg
41+
:target: http://badge.fury.io/py/mlstatpy
4242

43-
.. image:: http://img.shields.io/pypi/dm/project_name.png
43+
.. image:: http://img.shields.io/pypi/dm/mlstatpy.png
4444
:alt: PYPI Package
45-
:target: https://pypi.python.org/pypi/project_name
46-
47-
.. image:: http://img.shields.io/github/issues/sdpython/mlstatpy.png
48-
:alt: GitHub Issues
49-
:target: https://github.com/sdpython/mlstatpy/issues
45+
:target: https://pypi.python.org/pypi/mlstatpy
5046

5147
.. image:: https://img.shields.io/badge/license-MIT-blue.svg
5248
:alt: MIT License
@@ -65,7 +61,15 @@ Xavier Dupré
6561

6662
.. image:: https://codecov.io/github/sdpython/mlstatpy/coverage.svg?branch=master
6763
:target: https://codecov.io/github/sdpython/mlstatpy?branch=master
64+
65+
.. image:: http://img.shields.io/github/issues/sdpython/mlstatpy.png
66+
:alt: GitHub Issues
67+
:target: https://github.com/sdpython/mlstatpy/issues
6868

69+
.. image:: https://badge.waffle.io/sdpython/mlstatpy.png?label=ready&title=Ready
70+
:alt: Waffle
71+
:target: https://waffle.io/sdpython/mlstatpy
72+
6973

7074
**Links:** `github <https://github.com/sdpython/mlstatpy/>`_,
7175
`documentation <http://www.xavierdupre.fr/app/mlstatpy/helpsphinx/index.html>`_,

_doc/sphinxdoc/source/phdoc_static/my-styles.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
margin-bottom: 5px;
1515
margin-top: 5px;
1616
font-size: 14;
17-
}
17+
}
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
% insère une entrée dans la bibliographie
2+
% 1 - identifiant
3+
% 2 - année
4+
% 3 - auteurs
5+
% 4 - titre
6+
% 5 - revue
7+
% 6 - volume
8+
% 7 - page début
9+
% 8 - page fin
10+
11+
\bibitemstyle{Chang1974} {1974} {C. L. Chang}
12+
{Finding prototypes for nearest neighbor classifiers}
13+
{IEEE Transactions on Computer}{23(11)}{1179}{1184}
14+
15+
\bibitemstyle{Hart1968} {1968} {P. E. Hart}
16+
{The Condensed nearest neighbor rule}
17+
{IEEE Transactions on Information Theory}{14}{515}{516}
18+
19+
\bibitemstyle{Bezdek2001} {2001} {J.C. Bezdek, L.I. Kuncheva}
20+
{Nearest prototype classifier designs: An experimental study}
21+
{International Journal of Intelligent Systems}{16(12)}{1445}{1473}
22+
23+
\bibitemstyle{Frasconi1997} {1997} {P. Frasconi, M. Gori, G. Soda}
24+
{Links between LVQ and Backpropagation}
25+
{Pattern Recognition Letters}{18}{303}{310}
26+
27+
\bibitemstyle{Kim2003} {2003} {Sang-Woon Kim, B.J. Oommen}
28+
{Enhancing prototype reduction schemes with LVQ3-type}
29+
{Pattern Recognition}{36}{1083}{1093}
30+
31+
\bibitemstyle{Kohonen1982} {1982} {T. Kohonen}
32+
{Self-organized formation of topologically correct feature maps}
33+
{Biol. Cybernet.}{43}{59}{69}
34+
35+
\bibitemstyle{Kohonen1995} {1995} {T. Kohonen}
36+
{Self-organizing Map}
37+
{Springer, Berlin}{}{0}{}
38+
39+
\bibitemstyle{Linde1980} {1980} {Y. Linde, A. Buzo, R. M. Gray}
40+
{An algorithm for vector quantizer design}
41+
{IEEE Transactions on Commun.}{28}{84}{95}
42+
43+
\bibitemstyle{Vakil2003} {2003} {Mohhamad-Taghi Vakil-Baghmisheh, Nikola Pavesic}
44+
{Premature clustering phenomenon and new training algorithms for LVQ}
45+
{Pattern Recognition}{36}{1901}{1912}
46+
47+
\bibitemstyle{Vapnik1998} {1998} {V. N. Vapnik}
48+
{Statistical Learning Theory}
49+
{Wiley, New York}{}{0}{}
50+

0 commit comments

Comments
 (0)