-
Notifications
You must be signed in to change notification settings - Fork 0
/
training.html
456 lines (442 loc) · 47.6 KB
/
training.html
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Generic Training
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="Deep.Net machine learning framework"/>
<meta name="author" content="Deep.Net developers"/>
<script src="https://code.jquery.com/jquery-1.8.0.js"></script>
<script src="https://code.jquery.com/ui/1.8.23/jquery-ui.js"></script>
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet"/>
<link type="text/css" rel="stylesheet" href="http://www.deepml.net/content/style.css" />
<script type="text/javascript" src="http://www.deepml.net/content/tips.js"></script>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
</head>
<body>
<div class="container">
<div class="masthead">
<ul class="nav nav-pills pull-right">
<li><a href="http://github.com/DeepMLNet/DeepNet">github page</a></li>
</ul>
<h3 class="muted"><a href="http://www.deepml.net/index.html">Deep.Net</a></h3>
</div>
<hr />
<div class="row">
<div class="span9" id="main">
<h1><a name="Generic-Training" class="anchor" href="#Generic-Training">Generic Training</a></h1>
<p>Deep.Net contains a powerful, generic function to train your model.
Together with the <a href="dataset.html">dataset handler</a> it provides the following functionality:</p>
<ul>
<li>initialization of the model's parameters</li>
<li>mini-batch training</li>
<li>logging of losses on the training, validation and test sets</li>
<li>automatic scheduling of the learning rate</li>
<li>
termination of training when
<ul>
<li>a desired validation loss is reached</li>
<li>a set number of iterations have been performed</li>
<li>there is no loss improvement on the validation set within a set number of iterations</li>
</ul>
</li>
<li>checkpointing allows the training state to be saved to disk and training to be restarted afterwards (useful when running on non-reliable hardware or on a compute cluster that pauses jobs or moves them around on the cluster's nodes)</li>
</ul>
<h3><a name="Example-model" class="anchor" href="#Example-model">Example model</a></h3>
<p>To demonstrate its use we return to our two-layer neural network model for classifying MNIST digits.</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l">1: </span>
<span class="l">2: </span>
<span class="l">3: </span>
<span class="l">4: </span>
<span class="l">5: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="fsharp"><span class="k">open</span> <span class="i">SymTensor</span>
<span class="k">open</span> <span class="i">SymTensor</span><span class="o">.</span><span class="i">Compiler</span><span class="o">.</span><span class="i">Cuda</span>
<span class="k">open</span> <span class="i">Models</span>
<span class="k">open</span> <span class="i">Datasets</span>
<span class="k">open</span> <span class="i">Optimizers</span>
</code></pre></td>
</tr>
</table>
<p>We load the MNIST dataset using the <code>Mnist.load</code> function using a validation to training ratio of 0.1.</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l">1: </span>
<span class="l">2: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span onmouseout="hideTip(event, 'fs1', 1)" onmouseover="showTip(event, 'fs1', 1)" class="i">mnist</span> <span class="o">=</span> <span class="i">Mnist</span><span class="o">.</span><span class="i">load</span> (<span class="k">__SOURCE_DIRECTORY__</span> <span class="o">+</span> <span class="s">"../../../Data/MNIST"</span>) <span class="n">0.1</span>
<span class="o">|></span> <span class="i">TrnValTst</span><span class="o">.</span><span class="i">ToCuda</span>
</code></pre></td>
</tr>
</table>
<p>Next, we define and instantiate a model using the MLP (multi-layer perceptron, i.e. multi-layer neural network) component.</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l"> 1: </span>
<span class="l"> 2: </span>
<span class="l"> 3: </span>
<span class="l"> 4: </span>
<span class="l"> 5: </span>
<span class="l"> 6: </span>
<span class="l"> 7: </span>
<span class="l"> 8: </span>
<span class="l"> 9: </span>
<span class="l">10: </span>
<span class="l">11: </span>
<span class="l">12: </span>
<span class="l">13: </span>
<span class="l">14: </span>
<span class="l">15: </span>
<span class="l">16: </span>
<span class="l">17: </span>
<span class="l">18: </span>
<span class="l">19: </span>
<span class="l">20: </span>
<span class="l">21: </span>
<span class="l">22: </span>
<span class="l">23: </span>
<span class="l">24: </span>
<span class="l">25: </span>
<span class="l">26: </span>
<span class="l">27: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span onmouseout="hideTip(event, 'fs2', 2)" onmouseover="showTip(event, 'fs2', 2)" class="i">mb</span> <span class="o">=</span> <span class="i">ModelBuilder</span><span class="o"><</span><span onmouseout="hideTip(event, 'fs3', 3)" onmouseover="showTip(event, 'fs3', 3)" class="i">single</span><span class="o">></span> <span class="s">"NeuralNetModel"</span>
<span class="c">// define symbolic sizes</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs4', 4)" onmouseover="showTip(event, 'fs4', 4)" class="i">nBatch</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs2', 5)" onmouseover="showTip(event, 'fs2', 5)" class="i">mb</span><span class="o">.</span><span class="i">Size</span> <span class="s">"nBatch"</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs5', 6)" onmouseover="showTip(event, 'fs5', 6)" class="i">nInput</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs2', 7)" onmouseover="showTip(event, 'fs2', 7)" class="i">mb</span><span class="o">.</span><span class="i">Size</span> <span class="s">"nInput"</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs6', 8)" onmouseover="showTip(event, 'fs6', 8)" class="i">nClass</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs2', 9)" onmouseover="showTip(event, 'fs2', 9)" class="i">mb</span><span class="o">.</span><span class="i">Size</span> <span class="s">"nClass"</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs7', 10)" onmouseover="showTip(event, 'fs7', 10)" class="i">nHidden</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs2', 11)" onmouseover="showTip(event, 'fs2', 11)" class="i">mb</span><span class="o">.</span><span class="i">Size</span> <span class="s">"nHidden"</span>
<span class="c">// define model parameters</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs8', 12)" onmouseover="showTip(event, 'fs8', 12)" class="i">mlp</span> <span class="o">=</span>
<span class="i">MLP</span><span class="o">.</span><span class="i">pars</span> (<span onmouseout="hideTip(event, 'fs2', 13)" onmouseover="showTip(event, 'fs2', 13)" class="i">mb</span><span class="o">.</span><span class="i">Module</span> <span class="s">"MLP"</span>)
{ <span class="i">Layers</span> <span class="o">=</span> [{<span class="i">NInput</span><span class="o">=</span><span onmouseout="hideTip(event, 'fs5', 14)" onmouseover="showTip(event, 'fs5', 14)" class="i">nInput</span>; <span class="i">NOutput</span><span class="o">=</span><span onmouseout="hideTip(event, 'fs7', 15)" onmouseover="showTip(event, 'fs7', 15)" class="i">nHidden</span>; <span class="i">TransferFunc</span><span class="o">=</span><span class="i">NeuralLayer</span><span class="o">.</span><span class="i">Tanh</span>}
{<span class="i">NInput</span><span class="o">=</span><span onmouseout="hideTip(event, 'fs7', 16)" onmouseover="showTip(event, 'fs7', 16)" class="i">nHidden</span>; <span class="i">NOutput</span><span class="o">=</span><span onmouseout="hideTip(event, 'fs6', 17)" onmouseover="showTip(event, 'fs6', 17)" class="i">nClass</span>; <span class="i">TransferFunc</span><span class="o">=</span><span class="i">NeuralLayer</span><span class="o">.</span><span class="i">SoftMax</span>}]
<span class="i">LossMeasure</span> <span class="o">=</span> <span class="i">LossLayer</span><span class="o">.</span><span class="i">CrossEntropy</span> }
<span class="c">// define variables</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs9', 18)" onmouseover="showTip(event, 'fs9', 18)" class="i">input</span> <span class="o">:</span> <span class="i">ExprT</span><span class="o"><</span><span onmouseout="hideTip(event, 'fs3', 19)" onmouseover="showTip(event, 'fs3', 19)" class="i">single</span><span class="o">></span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs2', 20)" onmouseover="showTip(event, 'fs2', 20)" class="i">mb</span><span class="o">.</span><span class="i">Var</span> <span class="s">"Input"</span> [<span onmouseout="hideTip(event, 'fs4', 21)" onmouseover="showTip(event, 'fs4', 21)" class="i">nBatch</span>; <span onmouseout="hideTip(event, 'fs5', 22)" onmouseover="showTip(event, 'fs5', 22)" class="i">nInput</span>]
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs10', 23)" onmouseover="showTip(event, 'fs10', 23)" class="i">target</span> <span class="o">:</span> <span class="i">ExprT</span><span class="o"><</span><span onmouseout="hideTip(event, 'fs3', 24)" onmouseover="showTip(event, 'fs3', 24)" class="i">single</span><span class="o">></span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs2', 25)" onmouseover="showTip(event, 'fs2', 25)" class="i">mb</span><span class="o">.</span><span class="i">Var</span> <span class="s">"Target"</span> [<span onmouseout="hideTip(event, 'fs4', 26)" onmouseover="showTip(event, 'fs4', 26)" class="i">nBatch</span>; <span onmouseout="hideTip(event, 'fs6', 27)" onmouseover="showTip(event, 'fs6', 27)" class="i">nClass</span>]
<span class="c">// instantiate model</span>
<span onmouseout="hideTip(event, 'fs2', 28)" onmouseover="showTip(event, 'fs2', 28)" class="i">mb</span><span class="o">.</span><span class="i">SetSize</span> <span onmouseout="hideTip(event, 'fs5', 29)" onmouseover="showTip(event, 'fs5', 29)" class="i">nInput</span> <span onmouseout="hideTip(event, 'fs1', 30)" onmouseover="showTip(event, 'fs1', 30)" class="i">mnist</span><span class="o">.</span><span class="i">Trn</span><span class="o">.</span>[<span class="n">0</span>]<span class="o">.</span><span class="i">Img</span><span class="o">.</span><span class="i">Shape</span><span class="o">.</span>[<span class="n">0</span>]
<span onmouseout="hideTip(event, 'fs2', 31)" onmouseover="showTip(event, 'fs2', 31)" class="i">mb</span><span class="o">.</span><span class="i">SetSize</span> <span onmouseout="hideTip(event, 'fs6', 32)" onmouseover="showTip(event, 'fs6', 32)" class="i">nClass</span> <span onmouseout="hideTip(event, 'fs1', 33)" onmouseover="showTip(event, 'fs1', 33)" class="i">mnist</span><span class="o">.</span><span class="i">Trn</span><span class="o">.</span>[<span class="n">0</span>]<span class="o">.</span><span class="i">Lbl</span><span class="o">.</span><span class="i">Shape</span><span class="o">.</span>[<span class="n">0</span>]
<span onmouseout="hideTip(event, 'fs2', 34)" onmouseover="showTip(event, 'fs2', 34)" class="i">mb</span><span class="o">.</span><span class="i">SetSize</span> <span onmouseout="hideTip(event, 'fs7', 35)" onmouseover="showTip(event, 'fs7', 35)" class="i">nHidden</span> <span class="n">100</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs11', 36)" onmouseover="showTip(event, 'fs11', 36)" class="i">mi</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs2', 37)" onmouseover="showTip(event, 'fs2', 37)" class="i">mb</span><span class="o">.</span><span class="i">Instantiate</span> <span class="i">DevCuda</span>
<span class="c">// loss expression</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs12', 38)" onmouseover="showTip(event, 'fs12', 38)" class="i">loss</span> <span class="o">=</span> <span class="i">MLP</span><span class="o">.</span><span onmouseout="hideTip(event, 'fs12', 39)" onmouseover="showTip(event, 'fs12', 39)" class="i">loss</span> <span onmouseout="hideTip(event, 'fs8', 40)" onmouseover="showTip(event, 'fs8', 40)" class="i">mlp</span> <span onmouseout="hideTip(event, 'fs9', 41)" onmouseover="showTip(event, 'fs9', 41)" class="i">input</span><span class="o">.</span><span class="i">T</span> <span onmouseout="hideTip(event, 'fs10', 42)" onmouseover="showTip(event, 'fs10', 42)" class="i">target</span><span class="o">.</span><span class="i">T</span>
</code></pre></td>
</tr>
</table>
<p>Note that the input and target matrices must be transposed, since the neural network model expects each sample to be a column in the matrix while the dataset provides a matrix where each row is a sample.</p>
<p>We instantiate the <a href="https://arxiv.org/abs/1412.6980">Adam</a> optimizer to minimize the loss and use its default configuration.</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l">1: </span>
<span class="l">2: </span>
<span class="l">3: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="fsharp"><span class="c">// optimizer</span>
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs13', 43)" onmouseover="showTip(event, 'fs13', 43)" class="i">opt</span> <span class="o">=</span> <span class="i">Adam</span> (<span onmouseout="hideTip(event, 'fs12', 44)" onmouseover="showTip(event, 'fs12', 44)" class="i">loss</span>, <span onmouseout="hideTip(event, 'fs11', 45)" onmouseover="showTip(event, 'fs11', 45)" class="i">mi</span><span class="o">.</span><span class="i">ParameterVector</span>, <span class="i">DevCuda</span>)
<span class="k">let</span> <span onmouseout="hideTip(event, 'fs14', 46)" onmouseover="showTip(event, 'fs14', 46)" class="i">optCfg</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs13', 47)" onmouseover="showTip(event, 'fs13', 47)" class="i">opt</span><span class="o">.</span><span class="i">DefaultCfg</span>
</code></pre></td>
</tr>
</table>
<p>In previous example we have written a simple optimization loop by hand.
Here instead, we will employ the generic training function provided by Deep.Net.</p>
<h2><a name="Defining-a-Trainable" class="anchor" href="#Defining-a-Trainable">Defining a Trainable</a></h2>
<p>The generic training function works on any object that implements the <code>Train.ITrainable<'Smpl, 'T></code> interface where <code>'Smpl</code> is a sample record type (see <a href="dataset.html">dataset handling</a>) and <code>'T</code> is the data type of the model parameters, e.g. <code>single</code>.
The easiest way to create an ITrainable from a symbolic loss expression is to use the <code>Train.trainableFromLossExpr</code> function.
This function has the signature</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l">1: </span>
<span class="l">2: </span>
<span class="l">3: </span>
<span class="l">4: </span>
<span class="l">5: </span>
<span class="l">6: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="fsharp"><span class="k">val</span> <span class="i">trainableFromLossExpr</span> <span class="o">:</span> <span class="i">modelInstance</span><span class="o">:</span><span class="i">ModelInstance</span><span class="o"><</span><span class="o">'</span><span class="i">T</span><span class="o">></span> <span class="k">-></span>
<span class="i">loss</span><span class="o">:</span><span class="i">ExprT</span><span class="o"><</span><span class="o">'</span><span class="i">T</span><span class="o">></span> <span class="k">-></span>
<span class="i">varEnvBuilder</span><span class="o">:</span>(<span class="o">'</span><span class="i">Smpl</span> <span class="k">-></span> <span class="i">VarEnvT</span>) <span class="k">-></span>
<span class="i">optimizer</span><span class="o">:</span><span class="i">IOptimizer</span><span class="o"><</span><span class="o">'</span><span class="i">T</span>,<span class="o">'</span><span class="i">OptCfg</span>,<span class="o">'</span><span class="i">OptState</span><span class="o">></span> <span class="k">-></span>
<span class="i">optCfg</span><span class="o">:</span><span class="o">'</span><span class="i">OptCfg</span> <span class="k">-></span>
<span class="i">ITrainable</span><span class="o"><</span><span class="o">'</span><span class="i">Smpl</span>,<span class="o">'</span><span class="i">T</span><span class="o">></span>
</code></pre></td>
</tr>
</table>
<p>The arguments have the following meaning.</p>
<ul>
<li><code>modelInstance</code> is the model instance containing the parameters of the model to be trained.</li>
<li><code>loss</code> is the loss expression to be minimized.</li>
<li><code>varEnvBuilder</code> is a user-provided function that takes an instance of user-provided type <code>'Smpl</code> and returns a variable environment to evaluate the loss expression on this sample(s). The sample below shows how to build a variable environment from a sample.</li>
<li><code>optimizer</code> is an instance of an optimizer. All optimizers in Deep.Net implement the <code>IOptimizer</code> interface.</li>
<li><code>optCfg</code> is the optimizer configuration to use. The learning rate in the specified optimizer configuration will be overwritten.</li>
</ul>
<p>Let us build a trainable for our model.
First, we need to define a function that creates a variable environment from a sample.</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l">1: </span>
<span class="l">2: </span>
<span class="l">3: </span>
<span class="l">4: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span onmouseout="hideTip(event, 'fs15', 48)" onmouseover="showTip(event, 'fs15', 48)" class="f">smplVarEnv</span> (<span onmouseout="hideTip(event, 'fs16', 49)" onmouseover="showTip(event, 'fs16', 49)" class="i">smpl</span><span class="o">:</span> <span class="i">MnistT</span>) <span class="o">=</span>
<span class="i">VarEnv</span><span class="o">.</span><span class="i">empty</span>
<span class="o">|></span> <span class="i">VarEnv</span><span class="o">.</span><span class="i">add</span> <span onmouseout="hideTip(event, 'fs9', 50)" onmouseover="showTip(event, 'fs9', 50)" class="i">input</span> <span onmouseout="hideTip(event, 'fs16', 51)" onmouseover="showTip(event, 'fs16', 51)" class="i">smpl</span><span class="o">.</span><span class="i">Img</span>
<span class="o">|></span> <span class="i">VarEnv</span><span class="o">.</span><span class="i">add</span> <span onmouseout="hideTip(event, 'fs10', 52)" onmouseover="showTip(event, 'fs10', 52)" class="i">target</span> <span onmouseout="hideTip(event, 'fs16', 53)" onmouseover="showTip(event, 'fs16', 53)" class="i">smpl</span><span class="o">.</span><span class="i">Lbl</span>
</code></pre></td>
</tr>
</table>
<p>The value of the symbolic variable <code>input</code> is set to the image of the MNIST sample and the symbolic variable <code>target</code> is set to the label in one-hot encoding.</p>
<p>We are now ready to construct the trainable.</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l">1: </span>
<span class="l">2: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span onmouseout="hideTip(event, 'fs17', 54)" onmouseover="showTip(event, 'fs17', 54)" class="i">trainable</span> <span class="o">=</span>
<span class="i">Train</span><span class="o">.</span><span class="i">trainableFromLossExpr</span> <span onmouseout="hideTip(event, 'fs11', 55)" onmouseover="showTip(event, 'fs11', 55)" class="i">mi</span> <span onmouseout="hideTip(event, 'fs12', 56)" onmouseover="showTip(event, 'fs12', 56)" class="i">loss</span> <span onmouseout="hideTip(event, 'fs15', 57)" onmouseover="showTip(event, 'fs15', 57)" class="i">smplVarEnv</span> <span onmouseout="hideTip(event, 'fs13', 58)" onmouseover="showTip(event, 'fs13', 58)" class="i">opt</span> <span onmouseout="hideTip(event, 'fs14', 59)" onmouseover="showTip(event, 'fs14', 59)" class="i">optCfg</span>
</code></pre></td>
</tr>
</table>
<h2><a name="Training-configuration" class="anchor" href="#Training-configuration">Training configuration</a></h2>
<p>Next, we need to specify the training configuration using the <code>Train.Cfg</code> record type.
For illustration purposes we write down the whole record instance; in practice you would copy <code>Train.defaultCfg</code> and change fields as necessary.</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l"> 1: </span>
<span class="l"> 2: </span>
<span class="l"> 3: </span>
<span class="l"> 4: </span>
<span class="l"> 5: </span>
<span class="l"> 6: </span>
<span class="l"> 7: </span>
<span class="l"> 8: </span>
<span class="l"> 9: </span>
<span class="l">10: </span>
<span class="l">11: </span>
<span class="l">12: </span>
<span class="l">13: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span onmouseout="hideTip(event, 'fs18', 60)" onmouseover="showTip(event, 'fs18', 60)" class="i">trainCfg</span> <span class="o">:</span> <span class="i">Train</span><span class="o">.</span><span class="i">Cfg</span> <span class="o">=</span> {
<span class="i">Seed</span> <span class="o">=</span> <span class="n">100</span>
<span class="i">BatchSize</span> <span class="o">=</span> <span class="n">10000</span>
<span class="i">LossRecordInterval</span> <span class="o">=</span> <span class="n">10</span>
<span class="i">Termination</span> <span class="o">=</span> <span class="i">Train</span><span class="o">.</span><span class="i">ItersWithoutImprovement</span> <span class="n">100</span>
<span class="i">MinImprovement</span> <span class="o">=</span> <span class="n">1e-7</span>
<span class="i">TargetLoss</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs19', 61)" onmouseover="showTip(event, 'fs19', 61)" class="i">None</span>
<span class="i">MinIters</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs20', 62)" onmouseover="showTip(event, 'fs20', 62)" class="i">Some</span> <span class="n">100</span>
<span class="i">MaxIters</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs19', 63)" onmouseover="showTip(event, 'fs19', 63)" class="i">None</span>
<span class="i">LearningRates</span> <span class="o">=</span> [<span class="n">1e-3</span>; <span class="n">1e-4</span>; <span class="n">1e-5</span>]
<span class="i">CheckpointDir</span> <span class="o">=</span> <span onmouseout="hideTip(event, 'fs19', 64)" onmouseover="showTip(event, 'fs19', 64)" class="i">None</span>
<span class="i">DiscardCheckpoint</span> <span class="o">=</span> <span class="k">false</span>
}
</code></pre></td>
</tr>
</table>
<p>The meaning of the fields is as follows.</p>
<ul>
<li><strong>Seed</strong> is the random seed for model parameter initialization.</li>
<li><strong>BatchSize</strong> is the size of mini-batches used for training and evaluating the losses.</li>
<li><strong>LossRecordInterval</strong> is the number of iterations to perform between evaluating the loss on the validation and test sets.</li>
<li>
<strong>Termination</strong> is the termination criterium and can have the following values:
<ul>
<li><code>Train.ItersWithImprovements cnt</code> to stop training after <code>cnt</code> iteraitons without improvement.</li>
<li><code>Train.IterGain gain</code> to train for <span class="math">\(\mathrm{gain} \cdot \mathrm{bestIter}\)</span> iterations where <span class="math">\(\mathrm{bestIter}\)</span> is the best iteration. Usually one would use <span class="math">\(\mathrm{gain} \approx 2.0\)</span>.</li>
<li><code>Train.Forever</code> disables the termination criterium.</li>
</ul>
</li>
<li><strong>MinImprovement</strong> is the minimum loss change to count as improvement and should be a small number.</li>
<li><strong>TargetLoss</strong> can be used to specify a target validation loss that stops training when achieved. Use <code>Some loss</code> or <code>None</code>.</li>
<li><strong>MinIters</strong> can be the minimum number of training iterations to perform in the form <code>Some iters</code>, or <code>None</code>.</li>
<li><strong>MaxIters</strong> can be a hard limit on the training iterations in the form <code>Some iters</code>, or <code>None</code>.</li>
<li><strong>LearningRates</strong> is a list of learning rates to use. Training starts with the first element and moves to the next one, when the termination criterium (specified by the field Termination) is triggered.</li>
<li><strong>CheckpointDir</strong> may specify a directory in the form <code>Some dir</code>. (see checkpoint section for details)</li>
<li><strong>DiscardCheckpoint</strong> prohibits loading of a checkpoint if it is <code>true</code>.</li>
</ul>
<h2><a name="Performing-the-training" class="anchor" href="#Performing-the-training">Performing the training</a></h2>
<p>Now training can be performed by calling the <code>Train.train</code> function.
It takes three arguments: a trainable, the dataset to use and the training configuration.
The dataset was already loaded above.</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l">1: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="fsharp"><span class="k">let</span> <span onmouseout="hideTip(event, 'fs21', 65)" onmouseover="showTip(event, 'fs21', 65)" class="i">result</span> <span class="o">=</span> <span class="i">Train</span><span class="o">.</span><span class="i">train</span> <span onmouseout="hideTip(event, 'fs17', 66)" onmouseover="showTip(event, 'fs17', 66)" class="i">trainable</span> <span onmouseout="hideTip(event, 'fs1', 67)" onmouseover="showTip(event, 'fs1', 67)" class="i">mnist</span> <span onmouseout="hideTip(event, 'fs18', 68)" onmouseover="showTip(event, 'fs18', 68)" class="i">trainCfg</span>
</code></pre></td>
</tr>
</table>
<p>This will produce output similar to</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l"> 1: </span>
<span class="l"> 2: </span>
<span class="l"> 3: </span>
<span class="l"> 4: </span>
<span class="l"> 5: </span>
<span class="l"> 6: </span>
<span class="l"> 7: </span>
<span class="l"> 8: </span>
<span class="l"> 9: </span>
<span class="l">10: </span>
<span class="l">11: </span>
<span class="l">12: </span>
<span class="l">13: </span>
<span class="l">14: </span>
<span class="l">15: </span>
<span class="l">16: </span>
<span class="l">17: </span>
<span class="l">18: </span>
<span class="l">19: </span>
<span class="l">20: </span>
<span class="l">21: </span>
<span class="l">22: </span>
<span class="l">23: </span>
<span class="l">24: </span>
<span class="l">25: </span>
<span class="l">26: </span>
<span class="l">27: </span>
<span class="l">28: </span>
<span class="l">29: </span>
<span class="l">30: </span>
<span class="l">31: </span>
<span class="l">32: </span>
<span class="l">33: </span>
<span class="l">34: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="fsharp"><span class="i">Initializing</span> <span class="i">model</span> <span class="i">parameters</span> <span class="k">for</span> <span class="i">training</span>
<span class="i">Training</span> <span class="k">with</span> <span class="i">Dataset</span> (<span class="n">54000</span> <span class="i">training</span>, <span class="n">6000</span> <span class="i">validation</span>, <span class="n">10000</span> <span class="i">test</span> <span class="i">Datasets</span><span class="o">.</span><span class="i">MnistTs</span>)
<span class="i">Using</span> <span class="i">learning</span> <span class="i">rate</span> <span class="n">0.001</span>
<span class="n">10</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.5739</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.4652</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.5173</span>
<span class="n">20</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.3686</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.3210</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.3583</span>
<span class="o">..</span><span class="o">.</span>
<span class="n">380</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0155</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1083</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1114</span>
<span class="n">390</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0146</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1082</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1113</span>
<span class="n">400</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0137</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1082</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1112</span>
<span class="n">410</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0129</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1082</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1112</span>
<span class="n">420</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0121</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1083</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1113</span>
<span class="n">430</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0114</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1083</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1113</span>
<span class="n">440</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0108</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1084</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1114</span>
<span class="n">450</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0102</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1085</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1115</span>
<span class="n">460</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0096</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1086</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1116</span>
<span class="n">470</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0091</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1087</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1118</span>
<span class="n">480</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0086</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1089</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1120</span>
<span class="n">490</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0081</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1090</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1121</span>
<span class="n">500</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0077</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1092</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1123</span>
<span class="n">510</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0073</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1093</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1125</span>
<span class="i">Trained</span> <span class="k">for</span> <span class="n">110</span> <span class="i">iterations</span> <span class="i">without</span> <span class="i">improvement</span>
<span class="i">Using</span> <span class="i">learning</span> <span class="i">rate</span> <span class="n">0.0001</span>
<span class="n">410</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0135</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1082</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1112</span>
<span class="n">420</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0134</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1082</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1112</span>
<span class="o">..</span><span class="o">.</span>
<span class="n">510</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0123</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1083</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1113</span>
<span class="i">Trained</span> <span class="k">for</span> <span class="n">110</span> <span class="i">iterations</span> <span class="i">without</span> <span class="i">improvement</span>
<span class="i">Using</span> <span class="i">learning</span> <span class="i">rate</span> <span class="n">1e-05</span>
<span class="n">410</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0136</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1082</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1112</span>
<span class="n">420</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0136</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1082</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1112</span>
<span class="o">..</span><span class="o">.</span>
<span class="n">510</span><span class="o">:</span> <span class="i">trn</span><span class="o">=</span> <span class="n">0.0134</span> <span class="k">val</span><span class="o">=</span> <span class="n">0.1082</span> <span class="i">tst</span><span class="o">=</span> <span class="n">0.1112</span>
<span class="i">Trained</span> <span class="k">for</span> <span class="n">110</span> <span class="i">iterations</span> <span class="i">without</span> <span class="i">improvement</span>
<span class="i">Training</span> <span class="i">completed</span> <span class="i">after</span> <span class="n">400</span> <span class="i">iterations</span> <span class="k">in</span> <span class="n">00</span><span class="o">:</span><span class="n">30</span><span class="o">:</span><span class="n">07.6179551</span> <span class="i">because</span> <span class="i">NoImprovement</span>
</code></pre></td>
</tr>
</table>
<p>While training is executed you can press the <code>q</code> key to stop training immediately and the <code>d</code> key to switch to the next learning rate specified in the configuration.</p>
<p>During training the parameters that produce the best validation loss are saved each time the losses are evaluated (as set by the <code>LossRecordInterval</code> field in the training configuration).
When the validation loss does not improve for the set number of iterations (field <code>Termination</code> in the training configuration), the best parameters are restored and the next learning rate (field <code>LearningRates</code>) from the configuration is used.
This explains why the iteration count resets by 100 steps, each time the loss stops improving.</p>
<p>The best validation lost is achieved around iteration 400, then the model starts to overfit.
Decreasing the learning rate does not help in this case, thus training is terminated after exhausting the list of learning rates.</p>
<h2><a name="Training-result-and-log" class="anchor" href="#Training-result-and-log">Training result and log</a></h2>
<p>The return value of <code>Train.train</code> is a record of type <code>TrainingResult</code> that contains the training results and the training log.</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l">1: </span>
<span class="l">2: </span>
<span class="l">3: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="fsharp"><span onmouseout="hideTip(event, 'fs22', 69)" onmouseover="showTip(event, 'fs22', 69)" class="f">printfn</span> <span class="s">"Termination reason is </span><span class="pf">%A</span><span class="s"> after </span><span class="pf">%A</span><span class="s">"</span> <span onmouseout="hideTip(event, 'fs21', 70)" onmouseover="showTip(event, 'fs21', 70)" class="i">result</span><span class="o">.</span><span class="i">TerminationReason</span> <span onmouseout="hideTip(event, 'fs21', 71)" onmouseover="showTip(event, 'fs21', 71)" class="i">result</span><span class="o">.</span><span class="i">Duration</span>
<span onmouseout="hideTip(event, 'fs22', 72)" onmouseover="showTip(event, 'fs22', 72)" class="f">printfn</span> <span class="s">"The best iteration is </span><span class="e">\n</span><span class="s"></span><span class="pf">%A</span><span class="s">"</span> <span onmouseout="hideTip(event, 'fs21', 73)" onmouseover="showTip(event, 'fs21', 73)" class="i">result</span><span class="o">.</span><span class="i">Best</span>
<span onmouseout="hideTip(event, 'fs22', 74)" onmouseover="showTip(event, 'fs22', 74)" class="f">printfn</span> <span class="s">"The training log consists of </span><span class="pf">%d</span><span class="s"> entries."</span> (<span onmouseout="hideTip(event, 'fs23', 75)" onmouseover="showTip(event, 'fs23', 75)" class="t">List</span><span class="o">.</span><span onmouseout="hideTip(event, 'fs24', 76)" onmouseover="showTip(event, 'fs24', 76)" class="f">length</span> <span onmouseout="hideTip(event, 'fs21', 77)" onmouseover="showTip(event, 'fs21', 77)" class="i">result</span><span class="o">.</span><span class="i">History</span>)
</code></pre></td>
</tr>
</table>
<p>This prints</p>
<table class="pre"><tr><td class="lines"><pre class="fssnip"><span class="l">1: </span>
<span class="l">2: </span>
<span class="l">3: </span>
<span class="l">4: </span>
<span class="l">5: </span>
<span class="l">6: </span>
<span class="l">7: </span>
<span class="l">8: </span>
</pre></td>
<td class="snippet"><pre class="fssnip highlighted"><code lang="fsharp"><span class="i">Termination</span> <span class="i">reason</span> <span class="i">is</span> <span class="i">NoImprovement</span> <span class="i">after</span> <span class="n">00</span><span class="o">:</span><span class="n">29</span><span class="o">:</span><span class="n">28.1679299</span>
<span class="i">The</span> <span class="i">best</span> <span class="i">iteration</span> <span class="i">is</span>
{<span class="i">Iter</span> <span class="o">=</span> <span class="n">400</span>;
<span class="i">TrnLoss</span> <span class="o">=</span> <span class="n">0.01370835087</span>;
<span class="i">ValLoss</span> <span class="o">=</span> <span class="n">0.1082176194</span>;
<span class="i">TstLoss</span> <span class="o">=</span> <span class="n">0.1112449616</span>;
<span class="i">LearningRate</span> <span class="o">=</span> <span class="n">0.001</span>;}
<span class="i">The</span> <span class="i">training</span> <span onmouseout="hideTip(event, 'fs25', 78)" onmouseover="showTip(event, 'fs25', 78)" class="i">log</span> <span class="i">consists</span> <span class="k">of</span> <span class="n">51</span> <span class="i">entries</span><span class="o">.</span>
</code></pre></td>
</tr>
</table>
<p>It is possible to save the training result as a JSON file by calling <code>result.Save</code>.
This is useful when you use software or scripts to gather and analyze the results of multiple experiments.</p>
<h2><a name="Checkpointing" class="anchor" href="#Checkpointing">Checkpointing</a></h2>
<p>Checkpoint allows to training process to be interrupted and resumed later.
To enable checkpoint support, set the <code>CheckpointDir</code> of the configuration record to some suitable directory.
This directory has to be unique for each process.</p>
<p>When checkpoint support is enabled, the training functions traps <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms682541(v=vs.85).aspx">the CTRL+C and CTRL+BREAK signals</a>.
When such a signal is received, the training state (including the model parameters) is stored in the specified directory and the process is terminated with exit code 10.
In this case, the training function does not return to the user code.</p>
<p>When the program is executed again and the training function is called, it checks for a valid checkpoint.
If one is found, it is loaded and training resumes where it was interrupted.</p>
<p>To discard an existing checkpoint (for example if training or models parameters were changed), set <code>DiscardCheckpoint</code> to true.
This will delete any existing checkpoints from disk and restart training from the beginning.</p>
<h1><a name="Summary" class="anchor" href="#Summary">Summary</a></h1>
<p>With the generic training function you can train any model that has a loss expression.
The main effort is to write a small wrapper function that maps a training sample to a variable environment.
Various termination criteria, common in machine learning, are implemented.</p>
<div class="tip" id="fs1">val mnist : obj<br /><br />Full name: Training.mnist</div>
<div class="tip" id="fs2">val mb : obj<br /><br />Full name: Training.mb</div>
<div class="tip" id="fs3">Multiple items<br />val single : value:'T -> single (requires member op_Explicit)<br /><br />Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.single<br /><br />--------------------<br />type single = System.Single<br /><br />Full name: Microsoft.FSharp.Core.single</div>
<div class="tip" id="fs4">val nBatch : obj<br /><br />Full name: Training.nBatch</div>
<div class="tip" id="fs5">val nInput : obj<br /><br />Full name: Training.nInput</div>
<div class="tip" id="fs6">val nClass : obj<br /><br />Full name: Training.nClass</div>
<div class="tip" id="fs7">val nHidden : obj<br /><br />Full name: Training.nHidden</div>
<div class="tip" id="fs8">val mlp : obj<br /><br />Full name: Training.mlp</div>
<div class="tip" id="fs9">val input : obj<br /><br />Full name: Training.input</div>
<div class="tip" id="fs10">val target : obj<br /><br />Full name: Training.target</div>
<div class="tip" id="fs11">val mi : obj<br /><br />Full name: Training.mi</div>
<div class="tip" id="fs12">val loss : obj<br /><br />Full name: Training.loss</div>
<div class="tip" id="fs13">val opt : obj<br /><br />Full name: Training.opt</div>
<div class="tip" id="fs14">val optCfg : obj<br /><br />Full name: Training.optCfg</div>
<div class="tip" id="fs15">val smplVarEnv : smpl:'a -> 'b<br /><br />Full name: Training.smplVarEnv</div>
<div class="tip" id="fs16">val smpl : 'a</div>
<div class="tip" id="fs17">val trainable : obj<br /><br />Full name: Training.trainable</div>
<div class="tip" id="fs18">val trainCfg : obj<br /><br />Full name: Training.trainCfg</div>
<div class="tip" id="fs19">union case Option.None: Option<'T></div>
<div class="tip" id="fs20">union case Option.Some: Value: 'T -> Option<'T></div>
<div class="tip" id="fs21">val result : obj<br /><br />Full name: Training.result</div>
<div class="tip" id="fs22">val printfn : format:Printf.TextWriterFormat<'T> -> 'T<br /><br />Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn</div>
<div class="tip" id="fs23">Multiple items<br />module List<br /><br />from Microsoft.FSharp.Collections<br /><br />--------------------<br />type List<'T> =<br />  | ( [] )<br />  | ( :: ) of Head: 'T * Tail: 'T list<br />  interface IEnumerable<br />  interface IEnumerable<'T><br />  member GetSlice : startIndex:int option * endIndex:int option -> 'T list<br />  member Head : 'T<br />  member IsEmpty : bool<br />  member Item : index:int -> 'T with get<br />  member Length : int<br />  member Tail : 'T list<br />  static member Cons : head:'T * tail:'T list -> 'T list<br />  static member Empty : 'T list<br /><br />Full name: Microsoft.FSharp.Collections.List<_></div>
<div class="tip" id="fs24">val length : list:'T list -> int<br /><br />Full name: Microsoft.FSharp.Collections.List.length</div>
<div class="tip" id="fs25">val log : value:'T -> 'T (requires member Log)<br /><br />Full name: Microsoft.FSharp.Core.Operators.log</div>
</div>
<div class="span3">
<!-- <img src="http://www.deepml.net/img/logo.png" alt="Deep.Net logo" style="width:150px;margin:10px" /> -->
<ul class="nav nav-list" id="menu" style="margin-top: 20px;">
<li class="nav-header">Deep.Net</li>
<li><a href="http://www.deepml.net/index.html">Home page</a></li>
<li class="divider"></li>
<li><a href="http://nuget.org/packages/DeepNet">Get Library via NuGet</a></li>
<li><a href="http://github.com/DeepMLNet/DeepNet">Source Code on GitHub</a></li>
<li><a href="http://www.deepml.net/release-notes.html">Release Notes</a></li>
<li class="nav-header">Basics</li>
<li><a href="http://www.deepml.net/tensor.html">Working with Tensors</a></li>
<li><a href="http://www.deepml.net/model.html">Model Definition</a></li>
<li><a href="http://www.deepml.net/components.html">Model Components</a></li>
<li><a href="http://www.deepml.net/dataset.html">Dataset Handling</a></li>
<li><a href="http://www.deepml.net/training.html">Training</a></li>
<li class="nav-header">Advanced</li>
<li><a href="http://www.deepml.net/diff.html">Automatic Differentiation</a></li>
<li class="nav-header">Documentation</li>
<li><a href="http://www.deepml.net/reference/index.html">API Reference</a></li>
</ul>
</div>
</div>
</div>
<a href="http://github.com/DeepMLNet/DeepNet"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"/></a>
</body>
</html>