-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtutorial_fmnist.html
More file actions
403 lines (377 loc) · 20.2 KB
/
tutorial_fmnist.html
File metadata and controls
403 lines (377 loc) · 20.2 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="msvalidate.01" content="8A044F6B24E3A19810D766CAE2ACA17A" />
<meta name="description" content="NeVer Tools collects knowledge and insight about formal verification of Neural Networks.">
<meta name="author" content="Navendu Pottekkat | Stefano Demarchi">
<meta name="keywords" content="VNNLIB, NeVer, NeVerTools, CoCoNet, Neural Networks Verification">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="./assets/img/favicons/never2/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<title>NeVer 2 - fMNIST</title>
<!-- Favicons -->
<link rel="apple-touch-icon" sizes="180x180" href="./assets/img/favicons/never2/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="./assets/img/favicons/never2/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="./assets/img/favicons/never2/favicon-16x16.png">
<link rel="manifest" href="./assets/img/favicons/never2/site.webmanifest">
<link rel="mask-icon" href="./assets/img/favicons/never2/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="./assets/img/favicons/never2/favicon.ico">
<!-- Font Awesome icons (free version)-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js"
crossorigin="anonymous"></script>
<!-- Core theme CSS (includes Bootstrap)-->
<link href="css/styles.css" rel="stylesheet">
<!-- Fonts CSS-->
<link rel="stylesheet" href="css/heading.css">
<link rel="stylesheet" href="css/body.css">
<!-- Custom CSS-->
<style>
pre {
font-family: Consolas,"courier new";
font-size: 105%;
color: #dee2e6;
background-color: #2c3e50;
padding: 7px 14px;
border-radius: 5px;
}
.useful-link{
color: inherit;
text-decoration: underline;
font-family: SB Heading, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
font-weight: 600;
line-height: 1.2;
}
.code-instructions {
padding-bottom: 4px;
}
.responsive {
width: 100%;
max-width: 110%;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;
}
.font-large {
font-size:large;
}
.float-right {
float:right;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
padding-bottom: 5%;
}
.titles-tutorial {
text-align: center !important;
padding: 5%;
}
.flex-center {
display: flex;
justify-content: center;
align-items: center;
}
.blue-font {
color: #2c3e50;
}
#train, #overview {
color: #2c3e50;
}
#train b {
color: #2c3e50;
font-size:115%;
}
#overview p, #build p, #train p, #verify p {
font-size: 1.25rem;
font-weight: 300;
}
</style>
</head>
<body id="page-top">
<nav class="navbar navbar-expand-lg bg-secondary fixed-top" id="mainNav">
<div class="container"><a class="navbar-brand js-scroll-trigger" href="#page-top">NeVer 2 - Tutorials</a>
<button class="navbar-toggler navbar-toggler-right font-weight-bold bg-primary text-white rounded"
type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive"
aria-expanded="false" aria-label="Toggle navigation"><i class="fas fa-bars"></i></button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger"
href="#overview">Overview</a>
</li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger"
href="#build">Build</a>
</li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger"
href="#train">Training</a>
</li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger"
href="#verify">Verification</a>
</li>
</ul>
</div>
</div>
</nav>
<header class="masthead bg-primary text-white text-center">
<div class="container d-flex align-items-center flex-column">
<!-- Masthead Heading-->
<h1 class="masthead-heading mb-0">fMNIST tutorial</h1>
<!-- Icon Divider-->
<div class="divider-custom divider-light">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-caret-down"></i></div>
<div class="divider-custom-line"></div>
</div>
<!-- Masthead Subheading-->
<p class="masthead-subheading font-weight-light mb-0">
Fashion MNIST is a dataset of Zalando's article images—consisting of a training set of 60,000 examples
and a test set of 10,000 examples. Each example is a 28x28 grayscale image, associated with a label from
10 classes. Fashion-MNIST is intended to serve as a direct drop-in replacement for the original MNIST
dataset for benchmarking machine learning algorithms. It shares the same image size and structure of
training and testing splits.
</p>
</div>
</header>
<!-- OVERVIEW SECTION -->
<section class="masthead page-section portfolio" id="overview">
<div class="container">
<!-- Portfolio Section Heading -->
<div class="text-center">
<h2 class="page-section-heading text-secondary mb-0 d-inline-block">Network Overview</h2>
</div>
<!-- Icon Divider -->
<div class="divider-custom">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-code"></i></div>
<div class="divider-custom-line"></div>
</div>
<!-- Example Section Content -->
<div class="text-center">
<div id="overview-description">
<p>The picture below shows the formal representation of the Convolutional Neural Network for this dataset.
The architecture consists of a convolutional block, followed by a MaxPooling and a Flattening operation;
then there are 3 Fully Connected layers with ReLU activation functions.
This network takes as input a 1x28x28 tensor and outputs a 1D vector of 10 elements.</p>
</div>
<br>
<img class="responsive" src="./assets/img/tutorials/fmnist/formal_graph.png" alt="Convolutional diagram">
</div>
</div>
</section>
<!-- BUILD SECTION -->
<section class="page-section bg-primary text-white mb-0" id="build">
<div class="container">
<!-- Contact Section Heading-->
<div class="text-center">
<h2 class="page-section-heading d-inline-block text-white">Network Construction</h2>
</div>
<!-- Icon Divider-->
<div class="divider-custom divider-light">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-hammer"></i></div>
<div class="divider-custom-line"></div>
</div>
<!-- Contact Section Content-->
<div class="text-left font-large">
<div id="build-network">
<br>
<div>
<p class="lead">
In NeVer2 you can select the necessary blocks from the left toolbar;
the requested nodes will appear on the canvas with default parameters.
You can drag and drop them to any position in the canvas.
To edit their parameters you can just double-click or right-click -> "Edit", while
to delete them you can press DEL or right-click -> "Delete".
</p>
<div class="center flex-center">
<img style="padding-right: 10%;" src="./assets/img/tutorials/common/toolbar.png" alt="Right-Click menu options">
<img src="./assets/img/tutorials/common/options.png" alt="Right-Click menu options">
</div>
</div>
<br>
<div>
<p>
The first layer is defined by a Convolutional block, with the parameters defined as in the example;
the input shape is 1,28,28 and the convolution is operated with a 5 pixel kernel filter.
</p>
<div class="center flex-center">
<img style="padding-right: 10%;" src="./assets/img/tutorials/fmnist/input.png" alt="edit Convolutional block">
<img src="./assets/img/tutorials/fmnist/net1.png" alt="Convolutional block">
</div>
</div>
<br>
<div>
<p>
After this you can add a MaxPool block and edit the parameters accordingly. You can connect the two blocks
activating the drawing mode with the "Draw Line" button in the top-left corner or by pressing the CTRL+D
shortcut and clicking first on the starting block and then on the next block.
</p>
<div class="center flex-center">
<img style="padding-right: 10%;" src="./assets/img/tutorials/common/drawLine.png" alt="Toolbar with highlighted Draw Line button">
<img src="./assets/img/tutorials/fmnist/net2.png" alt="Convolutional and MaxPool NeVer2">
</div>
</div>
<br>
<div>
<p>
The next node is a Flatten operation, that unrolls the 3D tensor into a 1D array; this operation
is followed by a ReLU activation. In order to flatten the input to a 1D array the <i>axis</i>
parameter is set to 0.
</p>
<div class="center flex-center">
<img src="./assets/img/tutorials/fmnist/net3.png" alt="MaxPool and Flatten node">
</div>
</div>
<br>
<div>
<p>
Finally the three Fully Connected layers resize the dimension to 1000, 100 and 10 neurons: this
operation is performed by editing the <i>out_features</i> parameter. Each Fully Connected is
followed by a ReLU activation.
</p>
<div class="center flex-center">
<img class="responsive" src="./assets/img/tutorials/fmnist/network_complete.png" alt="Flatten and ReLU NeVer2">
</div>
</div>
</div>
</div>
</div>
</section>
<!-- TRAIN SECTION -->
<section class="page-section" id="train">
<div class="container">
<!-- Contact Section Heading-->
<div class="text-center">
<h2 class="page-section-heading text-secondary d-inline-block mb-0">Network Training</h2>
</div>
<!-- Icon Divider-->
<div class="divider-custom">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-brain"></i></div>
<div class="divider-custom-line"></div>
</div>
<!-- Contact Section Content-->
<div class="text-left font-large">
<div id="train-network">
<br>
<div>
<p>
Once the network is completed, you can train it. In the menu bar select "Learn..." -> "Train":
the training window appears, where you can select the dataset and the learning parameters.
Given the popularity of this dataset, both MNIST and fMNIST are available by default; the first
time they will be downloaded and then will be stored in the NeVer2 working directory. There is
a pre-defined dataset transform tailored for both convolutional and linear MNIST and fMNIST
networks, which compose 2 or 3 transforms: <i>pilToTensor</i> and <i>Normalize(1, 0.5)</i> in
both cases, <i>Flatten</i> in the linear case only.
</p>
<img class="center" src="./assets/img/tutorials/fmnist/training_setup.png" alt="Training parameters of the network">
<p>
The learning parameters can be set as follows:<br><br>
<b><i>Optimizer</i></b>: at the moment only "Adam" (adaptive moment estimation) is supported, being
the most popular and effective gradient based optimization algorithm. Once selected, you can edit all
its related parameters.<br><br>
<b><i>Learning Rate Scheduler</i></b>: like the Optimizer, only "ReduceLROnPlateau" is supported. It adjusts the
learning rate only when a plateau in model performance is detected, e.g. no change for a given number of
training epochs.<br><br>
<b><i>Loss Function</i></b>: you can choose between "Cross Entropy" and "MSE Loss", depending on the network
structure.<br><br>
<b><i>Precision Metric</i></b>: you can choose between "Inaccuracy" and "MSE loss".<br><br>
<b><i>Epochs</i></b>: it defines the steps that the learning algorithm will perform through the training process.
<br><br>
<b><i>Validation Percentage</i></b>: (a number between 0 and 1) indicates the percentage of the dataset to use
as the validation set.<br><br>
<b><i>Training batch size</i></b> and <b><i>Validation batch size</i></b>: it defines the dimension of the
training batches.<br><br>
<b><i>Cuda</i></b>: it allows to take advantage of NVidia GPU architecture for the computation.<br><br>
<b><i>Train patience</i></b> <i>(optional)</i>: the number of epochs in which the loss may not decrease
before the training procedure is interrupted with early stopping.<br><br>
<b><i>Checkpoints root</i></b> <i>(optional)</i>: where to store the checkpoints of the training strategy, by
default the working directory of NeVer2.<br><br>
<b><i>Verbosity level</i></b> <i>(optional)</i>: how many batches between training log prints (default 1).
</p>
</div>
<br>
<div>
<p>
Once the parameters are set, clicking "Train Network" runs the training. Logs are printed in a box
below the buttons.
</p>
<br>
<img class="center" src="./assets/img/tutorials/fmnist/training_loss.png" alt="Training Results">
</div>
<div>
<p>
The <b>Best Loss Score</b> label indicates the smallest training loss; in this case,
with a 10 epoch long training the best loss is 0.0136, corresponding to 1.36%. Looking
at the following diagram shows how increasing the training epochs improves significantly
the training loss.
</p>
<img class="center" src="./assets/img/tutorials/fmnist/fmnist_loss.png" width="60%" alt="Training Loss">
</div>
</div>
</div>
</div>
</section>
<!-- VERIFY SECTION -->
<section class="page-section bg-primary text-white mb-0" id="verify">
<div class="container">
<div class="text-center">
<h2 class="page-section-heading d-inline-block text-white">Network Verification</h2>
</div>
<!-- Icon Divider-->
<div class="divider-custom divider-light">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-check"></i></div>
<div class="divider-custom-line"></div>
</div>
<div class="text-left font-large">
<div id="verify-network">
<p class="lead">
At the moment we do not support verification for Convolutional Neural Networks.
This section will be updated in time.
</p>
</div>
</div>
</div>
</section>
<footer class="footer text-center">
<div class="container">
<div class="row">
<!-- Footer Location-->
<div class="col-lg-4 mb-5 mb-lg-0">
<h4 class="mb-4"></h4>
<p class="pre-wrap lead mb-0"> </p>
</div>
<div class="col-lg-4 mb-5 mb-lg-0">
<h4 class="mb-4">Powered by AIMS-Lab</h4>
<a target="_blank" href="http://www.aimslab.org">
<img class="img-footer" src="assets/svg/unige.svg" alt="UniGE">
</a>
</div>
</div>
</br></br>
This tutorial was provided by Andrea Gimelli, Karim Pedemonte and Giacomo Rosato.
</div>
</footer>
<!-- Copyright Section -->
<section class="copyright py-4 text-center text-white">
<div class="container"><small class="pre-wrap"><a target="_blank" href="https://github.com/NeVerTools/NeVerTools.github.io/blob/master/LICENSE">MIT Licensed</a> | neuralverification.org 2021 | Hosted with ❤ by <a href="https://github.com/" target="_blank">GitHub</a></small></div>
</section>
<!-- Scroll to Top Button (Only visible on small and extra-small screen sizes) -->
<div class="scroll-to-top d-lg-none position-fixed"><a
class="js-scroll-trigger d-block text-center text-white rounded" href="#page-top"><i
class="fa fa-chevron-up"></i></a></div>
<!-- Bootstrap core JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
<!-- Third party plugin JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js"></script>
<!-- Core theme JS -->
<script src="js/scripts.js"></script>
<!-- GitHub buttons -->
<script async defer src="https://buttons.github.io/buttons.js"></script>
</body>
</html>