-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnever2_tutorialACC.html
More file actions
435 lines (406 loc) · 23 KB
/
never2_tutorialACC.html
File metadata and controls
435 lines (406 loc) · 23 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<title>NeVer 2</title>
<!-- Favicons -->
<link rel="apple-touch-icon" sizes="180x180" href="./assets/img/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="./assets/img/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="./assets/img/favicons/favicon-16x16.png">
<link rel="manifest" href="./assets/img/favicons/site.webmanifest">
<link rel="mask-icon" href="./assets/img/favicons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="./assets/img/favicons/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: 110%;
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">Building</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">Neural Network for the ACC dataset</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">
ACC, Adaptive Cruise Control, is used to
maintain a constant safe distance between the host vehicle and
the leading vehicle to avoid rear end collisions. It is an
automotive feature that allows the speed of the vehicle to
adapt to the traffic environment.
ACC operates in distance control mode and velocity control mode.
The vehicle’s speed is controlled via engine throttle control and limited brake operation.
The intervehicular distance between the vehicle is measured. Desired speed is obtained from the distance measured.
ACC dataset is a collection of data made up of 3 input values and 1 output value.
The input values are: the vehicle's speed, the speed relative to the car in front and the distance beetween them.
The output value is meant to estabilish if the car has to decrease his speed or accelerate.
</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-left"></div>
<div id="overview-description">
<p>
In the picture below there is a formal representation of the Fully Connected Neural Network we're going to train.
We are going to use 3 Hidden Layers with ReLU as the neuron activation function.
As said before, the ACC Dataset has three input and one output parameter.
</p>
</div>
<br>
<img src="./assets/img/tutorials/ACC/ACC_graph.png" alt="Fully connected diagram" class="center responsive">
</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">Building the Network</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>Once NeVer2 is open, select the required blocks in the toolbar on the left. In this case we're going to use
only Fully Connected and ReLU blocks.</p>
<img class="center" src="./assets/img/tutorials/common/toolbar.png" alt="Toolbar with highlighted Fully Connected and ReLU blocks">
</div>
<br>
<div>
<p>When clicked, the desired nodes will appear on the canvas with default parameters. Drag and drop them any position you like on the canvas.
To edit their parameters double-click or right-click and click "edit". To delete them right-click and click "delete" or press the DEL key.</p>
<img class="center" src="./assets/img/tutorials/common/options.png" alt="Right-Click menu options">
</div>
<br>
<br>
<div>
<p>To begin, we're going to select a Fully Connected block and set the "in_features" and "out_features" parameters to values 3 and 64 respectively.</p>
<img class="center" src="./assets/img/tutorials/ACC/fc.png" alt="Fully Connected block NeVer2">
</div>
<br>
<div>
<p> After selecting a ReLU node, we can connect them activating the drawing mode with the "Draw Line" button
(in the top-left corner) or by pressing the CTRL+D shortcut and clicking on them (first click on Fully Connected
block and then on the ReLU node).</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/ACC/fcAndReLU.png" alt="Fully Connected and ReLU NeVer2">
</div>
</div>
<br>
<div>
<p> We're now going to add a new Fully Connected block and set its "out_features" parameter to 32, then link the previous ReLU node to it.
By connecting the ReLU node the new Fully Connected block "in_features" parameter is automatically set to the ReLU output value (64).
Next, we're adding another ReLU node and we're connecting the previous Fully Connected node to it.</p>
<div class="center flex-center">
<img src="./assets/img/tutorials/ACC/fcAndReLUx2.png" alt="Fully Connected and ReLU NeVer2">
</div>
</div>
<br>
<div>
<p> We're now going to repeat the last two steps one more time, creating a Fully Connected node with "out_features" set to 16,
and adding a subsequent ReLU block.</p>
<div class="center flex-center">
<img src="./assets/img/tutorials/ACC/fcAndReLUx3.png" alt="Fully Connected and ReLU NeVer2">
</div>
</div>
<br>
<div>
<p>Lastly we're going to add a final Fully Connected block and set its "out_features" parameter to 1.</p>
<div class="center flex-center">
<img src="./assets/img/tutorials/ACC/finalFC.png" alt="Final Fully Connected Neural Network NeVer2">
</div>
</div>
<br>
</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">Training the Network</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> Now that we have successfully built the network, we need to train it.
We're going to click on the "learn" button in the menu bar, then click on the "train" button and select the ACC custom dataset (TXT or CSV format).
The target index field contains the input size.</p>
<img class="center" src="./assets/img/tutorials/ACC/customDataSet.png" alt="Screen of the select custom dataset menu">
</div>
<br>
<div>
<p>Then, we're going to set the training parameters according to the following image.</p>
<img class="center" src="./assets/img/tutorials/ACC/trainNetwork.png" alt="Training parameters of the network">
<p>The <b>Dataset transform</b> is not required for datasets not related to MNIST.<br><br>
Concerning the <b>Optimizer</b>, the only one available at the moment is "Adam" ("adaptive moment estimation"),
the most popular and effective gradient based optimization algorithm, so that's what we're using.
You may also change Adam's default parameters, if you wish.<br><br>
The <b>Learning rate scheduler</b> available is "ReduceLROnPlateau", which will adjust the learning rate when a plateau
in model performance is detected, e.g. no change for a given number of training epochs.<br><br>
As <b>Loss Function</b> you can choose between "Cross Entropy" and "MSE Loss"; the choice depends on the neural network structure.
In our case we are going to use the second one.<br><br>
As <b>Metric function</b> there are two options "inaccuracy", that ..., and "MSE loss", of which you can change the reduction type.<br><br>
Then, we have the <b>Epochs</b> number, that defines the number times that the learning algorithm will work through the entire training dataset.<br><br>
The next parameter <b>Validation percentage</b> (a number between 0 and 1) refers to the percentage of the dataset to use as the validation set.<br><br>
To split your dataset computation you can set the next two constants, <b>Training batch size</b> and <b>Validation batch size</b>, that is recommended
with large datasets. We're going to set 256 and 128 respectively.<br><br>
Finally, if you want to use a Nvidia GPU during the training you can set <b>Cuda</b> to True.<br><br>
The last three parameters are optional and correspond to:<br>
-<b>Train patience</b>: The number of epochs in which the loss may not decrease before the training procedure is interrupted with early stopping.<br>
-<b>Checkpoints root</b>: where to store the checkpoints of the training strategy.<br>
-<b>Verbosity level</b>: After how many batch the strategy prints information about how the training is going.
</p>
</div>
<br>
<div>
<p>Finally we're going to click on the "Train Network" button and wait for the results.</p>
<img class="center" src="./assets/img/tutorials/ACC/results.png" alt="Training Results">
</div>
<br>
<div>
<p> The <b>Best Loss Score</b> label indicates the network's error percentage. In this case, with a 10 epoch long training we got about 9.8e-05, corresponding to
a 0.0098% error rate!<br>
As shown in the graph below, if you train the network for more epochs you will notice an improvement in the error percentage.</p>
<br>
<img class="center" src="./assets/img/tutorials/ACC/stats.png" alt="error rate related to epochs number">
</div>
</div>
</div>
</div>
</section>
<!-- VERIFY SECTION -->
<section class="page-section bg-primary text-white mb-0" id="verify">
<div class="container">
<!-- Contact Section Heading-->
<div class="text-center">
<h2 class="page-section-heading d-inline-block text-white">Verifying the Network</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>
<!-- Contact Section Content-->
<div class="text-left font-large">
<div id="verify-network">
<br>
<h1 class="titles-tutorial">TODO</h1>
</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>
<!-- Footer Social Icons-->
<div class="col-lg-4 mb-5 mb-lg-0">
<h4 class="mb-4">Around the Web</h4>
<!-- LINKEDIN -->
<li class="list-inline-item">
<a target="_blank" href="https://google.com">
<span class="fa-stack fa-lg">
<i class="fas fa-circle fa-stack-2x"></i>
<i class="fab fa-linkedin fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<!-- MEDIUM (?) -->
<li class="list-inline-item">
<a target="_blank" href="https://google.com">
<span class="fa-stack fa-lg">
<i class="fas fa-circle fa-stack-2x"></i>
<i class="fab fa-medium fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<!-- GITHUB -->
<li class="list-inline-item">
<a target="blank" href="https://github.com/NeVerTools">
<span class="fa-stack fa-lg">
<i class="fas fa-circle fa-stack-2x"></i>
<i class="fab fa-github fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<!-- TWITTER -->
<li class="list-inline-item">
<a target="blank" href="https://google.com">
<span class="fa-stack fa-lg">
<i class="fas fa-circle fa-stack-2x"></i>
<i class="fab fa-twitter fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
</div>
<!-- Footer About Text-->
<div class="col-lg-4">
<h4 class="mb-4"></h4>
<p class="pre-wrap lead mb-0"> </p>
</div>
</div>
</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>
<!-- GitHub buttons -->
<a target="_blank" href="https://startbootstrap.com/theme/freelancer" data-color-scheme="no-preference: dark; light: dark; dark: dark;" data-icon="octicon-repo-template" aria-label="Use this template">Use this template</a>
</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>