forked from IPAIopen/NumDL-CourseNotes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10-NumDNN-IntroDeepLearning.tex
More file actions
357 lines (246 loc) · 8.43 KB
/
10-NumDNN-IntroDeepLearning.tex
File metadata and controls
357 lines (246 loc) · 8.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
\documentclass[12pt,fleqn,handout]{beamer}
\input{beamerStyle.tex}
\input{abbrv.tex}
\date{}
\title{Introduction to Deep Neural Networks}
\subtitle{Numerical Methods for Deep Learning}
\begin{document}
\makebeamertitle
\section{Motivation} % (fold)
\label{sec:motivation}
\begin{frame}[fragile]\frametitle{Why Deep Networks?}
\begin{itemize}
\item Universal approximation theorem of NN suggests that we can approximate {\bf any} function by
two layers.
\item But - The width of the layer can be very large ${\cal O}(n\cdot n_f)$
\item
Deeper architectures can lead to more efficient descriptions of the problem.
\item
No real proof but lots of practical experience.
\end{itemize}
\end{frame}
\begin{frame}[fragile]\frametitle{Deep Neural Networks}
How deep is deep?
We will answer this question later ...
\bigskip
\pause
Until recently, the standard architecture was
\begin{eqnarray*}
\bfY_1 &=& \sigma(\bfK_0\bfY_0 + b_0) \\
\vdots & =& \vdots \\
\bfY_N &=& \sigma(\bfK_{N-1} \bfY_{N-1}+ b_{N-1})
\end{eqnarray*}
\bigskip
\pause
And use $\bfY_N$ to classify. This leads to the optimization problem
$$
\min_{\bfK_{0,\ldots,N-1},\bfb_{0,\ldots,N-1},\bfW} \ \ E\left(\bfW \bfY_N(\bfK_1,\ldots,\bfK_{N-1},b_1,\ldots, b_{N-1}) , \bfC^{\rm obs} \right)
$$
\end{frame}
\begin{frame}[fragile]\frametitle{Example: The Alexnet~\cite{KrizhevskySutskeverHinton2012} for Image Classification}
\begin{columns}
\column{.6\textwidth}
\begin{itemize}
\item Complex architectures
\item trained on multiple GPUs
\item $\approx $ 60 million weights
\end{itemize}
\column{.4\textwidth}
\begin{center}
\includegraphics[width=2.9cm]{Alexnet-wikimedia}
\end{center}
\end{columns}
\end{frame}
\begin{frame}[fragile]\frametitle{Deep Neural Networks in Practice}
\begin{columns}
\column{.75\textwidth}
(Some) challenges:
\begin{itemize}
\item
Computational costs (architecture have millions or billions of parameters)
\item
difficult to design
\item
difficult to train (exploding/vanishing gradients)
\item
unpredictable performance
\end{itemize}
\bigskip
\invisible<beamer|1>{
In 2015, He et al.~\cite{he2016deep,he2016identity} came with a new architecture that solves many of the problems}
\column{.25\textwidth}
\invisible<beamer|1>{
\includegraphics[width=30mm]{resnet-wikimedia}}
\end{columns}
\only<beamer|2>{}
\end{frame}
% section motivation (end)
\section{Residual Neural Networks} % (fold)
\label{sec:residual_neural_networks}
\begin{frame}[fragile]\frametitle{Simplified Residual Neural Network}
Residual Network
\bigskip
\begin{eqnarray*}
\bfY_1 &=& \bfY_0 + \sigma(\bfK_0\bfY_0 + b_0) \\
\vdots &=& \vdots \\
\bfY_N &=& \bfY_{N-1} + \sigma( \bfK_{N-1}\bfY_{N-1} + b_{N-1})
\end{eqnarray*}
And use $\bfY_N$ to classify. This leads to the optimization problem
$$
\min_{\bfK_{0,\ldots,N-1},\bfb_{0,\ldots,N-1},\bfW} \ \ E\left(\bfW\bfY_N(\bfK_1,\ldots,\bfK_{N-1},b_1,\ldots, b_{N-1}), \bfC^{\rm obs} \right)
$$
\bigskip
\begin{center}
Leads to smoother objective function~\cite{LiEtAl2017}.
\end{center}
\end{frame}
\begin{frame}[fragile]\frametitle{Stability of Deep Residual Networks}
Why are ResNets more stable?
A small change
\begin{eqnarray*}
\bfY_1 &=& \bfY_0 + h \sigma(\bfK_0 \bfY_0 + b_0) \\
\vdots &=& \vdots \\
\bfY_N &=& \bfY_{N-1} + h\sigma(\bfK_{N-1} \bfY_{N-1} + b_{N-1})
\end{eqnarray*}
\bigskip
\pause
This is nothing but a forward Euler discretization
of the Ordinary Differential Equation (ODE)
$$ \dot{\bfY}(t) = \sigma(\bfK(t) \bfY(t) + b(t)), \quad \quad \bfY(0) = \bfY_0 $$
We can understand the behavior by learning the dynamics of nonlinear ODEs~\cite{HaberRuthotto2017,E2017}.
\end{frame}
% section residual_neural_networks (end)
\section{Crash Course: ODE} % (fold)
\label{sec:crash_course_ode}
\begin{frame}[fragile]\frametitle{Crash Course on ODEs}
Given the ODE
$$ \dot{\bfy} = f(t,\bfy) $$
Assumptions:
\begin{enumerate}
\item $f$ differentiable with Jacobian
$$ \bfJ(t,\bfy) = \left({\frac {\partial f}{\partial \bfy}}\right)^\top$$
\item $\bfJ$ changes sufficiently slowly in time
\end{enumerate}
Then (see also~\cite{AscherPetzold1998,AscherGreif2011,Ascher2010})
\begin{itemize}
\item If $Re({\rm eig}(\bfJ)) > 0\quad \quad \rightarrow$\ Unstable
\item If $Re({\rm eig}(\bfJ)) < 0\quad \quad \rightarrow$\ Stable (converge to a stationary point)
\item If $Re({\rm eig}(\bfJ)) = 0\quad \quad \rightarrow$\ Stable, energy bounded
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Stability of Residual Network}
Assume forward propagation of single example $\bfy_0$
$$ \dot{\bfy}(t) = \sigma(\bfK(t) \bfy(t) + b(t)), \quad \quad \bfy(0) = \bfy_0 $$
\bigskip
\pause
The Jacobian is
$$
\bfJ(t) = {\rm diag}\left(\sigma'(\bfK(t) \bfy(t) + b(t))\right) \bfK(t)
$$
Here, $\sigma'(x) \geq 0$ for $\tanh$, ReLU, \ldots
\bigskip
\pause
Hence, problem is stable when
\begin{enumerate}
\item $\bfJ$ changes slowly in time
\item $Re({\rm eig}\bfK(t)) \leq 0$ for every $t$
\end{enumerate}
\pause
\begin{center}
Remember that we learn $\bfK$ $\leadsto$ ensure stability by regularization/constraints!
\end{center}
\end{frame}
\begin{frame}[fragile]\frametitle{Residual Network as a Path Planning Problem}
\begin{center}
\includegraphics[width=\textwidth]{PathPlanning}
\end{center}
\bigskip
\pause
Forward propagation in residual network (continuous)
$$ \dot{\bfY}(t) = \sigma( \bfK(t) \bfY(t) + b(t)), \qquad \bfY(0) = \bfY_0 $$
The goal is to plan a path (via $\bfK$ and $b$) such that the initial data can be linearly separated
\bigskip
\pause
Question: What is a layer, what is depth?
\end{frame}
\begin{frame}[fragile]\frametitle{Stability: Continuous vs. Discrete}
Assume $\bfK$ is chosen so that the (continuous) forward propagation is stable
$$ \dot{\bfY}(t) = \sigma( \bfK \bfY(t)+ b(t)), \qquad \bfY(0) = \bfY_0 $$
And assume we use the forward Euler method to discretize
$$ \bfY_{j+1} = \bfY_{j} + h \sigma( \bfK_j \bfY_j + b_j) $$
Is the network stable?
\bigskip
\pause
Not always ...
\end{frame}
\begin{frame}[fragile]\frametitle{Stability: A Simple Example}
Look at the simplest possible forward propagation
$$ \dot{\bfY}(t) = \lambda\bfY(t) $$
And assume we use the forward Euler to discretize
$$ \bfY_{j+1} = \bfY_{j} + h \lambda \bfY_j = (1+h\lambda) \bfY_j$$
Then the method is stable only if
$$ |1+h\lambda| \le 1 $$
\bigskip
Not every network is stable! Time step size depends on our Jacobian
\end{frame}
\newcommand{\image}[1]{\includegraphics[width=35mm,trim=50 0 70 0,clip=true]{images/E10_Stability/#1}}
\newcommand{\rottext}[1]{\rotatebox{90}{\hbox to 40mm{\hss #1\hss}}}
\newcommand{\imageDiff}[1]{\includegraphics[width=35mm,trim=50 0 0 0,clip=true]{images/E10_Stability/#1}}
\begin{frame}
\frametitle{Why you should care about stability - 1}
$$
\min_\theta \hf \|\bfY_N(\theta) - \bfC\|_F^2 \quad \quad \bfY_{j+1}(\theta) = \bfY_j(\theta) + \frac{10}{N} \tanh \left( \bfK \bfY_j(\theta) \right)
$$
where $\bfC = \bfY_{200}(1,1)$, $\bfY_0 \sim \mathcal{N}(0,1)$, and
$$
\bfK(\theta) = \begin{pmatrix} -\theta_1-\theta_2 & \theta_1 & \theta_2 \\
\theta_2 & -\theta_1-\theta_2 & \theta_1 \\
\theta_1 & \theta_2 & -\theta_1-\theta_2 \end{pmatrix}
$$
\begin{center}
\begin{tabular}{cc}
objective, $N=5$ & objective, $N=100$\\
\image{Phic} &
\image{Phif}
\end{tabular}
\pause
\textbf{\tcr{Next: Compare different inputs $\sim$ generalization}}
\end{center}
\end{frame}
\begin{frame}
\frametitle{Why you should care about stability - 2}
\begin{center}
\begin{tabular}{@{}c@{}c@{}c@{}c@{}}
& objective, $\bfY_0^{\rm train}$ & objective, $\bfY_0^{\rm test}$ & abs. diff\\
\rottext{unstable, $N=5$}
& \image{Phic}
& \image{Phict}
& \imageDiff{Phic-Phict}\\[-8mm]
\rottext{stable, $N=100$}
& \image{Phif}
& \image{Phift}
& \imageDiff{Phif-Phift}
\end{tabular}
\end{center}
\end{frame}
\begin{frame}[fragile]\frametitle{Stability: A Non-Trivial Example}
Consider the antisymmetric kernel model
$$
\bfK(t) = \bfK(t) - \bfK(t)^\top
$$
Here, $Re({\rm eig}(\bfJ)(t))= 0$ for all $\theta$.
\bigskip
\pause
Assume we use the forward Euler to discretize
$$ \bfY_{j+1} = \bfY_{j} + h \sigma( (\bfK_j-\bfK_j^\top) \bfY_j + b_j) $$
Tricky question: How to pick $h$ to ensure stability?
\pause
Answer: Impossible since eigenvalues of Jacobian are imaginary. Need other method than forward Euler.
\end{frame}
\begin{frame}[allowframebreaks]
\frametitle{References}
\bibliographystyle{abbrv}
\bibliography{NumDNN}
\end{frame}
\end{document}