-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
368 lines (302 loc) · 10.1 KB
/
index.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
<!DOCTYPE HTML>
<!-- author Marijus Gudiskis [email protected] -->
<html>
<head>
<title>Interactive neural network</title>
<!-- importing libraries -->
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script src="https://unpkg.com/[email protected]/dist/math.min.js" type="text/javascript"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Add icon library -->
<style>
body {font-family: Arial, Helvetica, sans-serif;}
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
-webkit-animation-name: fadeIn; /* Fade in the background */
-webkit-animation-duration: 0.1s;
animation-name: fadeIn;
animation-duration: 0.1s
}
/* Modal Content */
.modal-content {
position: fixed;
bottom: 0;
background-color: #fefefe;
width: 100%;
-webkit-animation-name: slideIn;
-webkit-animation-duration: 0.2s;
animation-name: slideIn;
animation-duration: 0.2s
}
/* The Close Button */
.close {
color: white;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
.modal-header {
padding: 2px 16px;
background-color: #5cb85c;
color: white;
}
.modal-body {padding: 2px 16px;}
/* Add Animation */
@-webkit-keyframes slideIn {
from {bottom: -300px; opacity: 0}
to {bottom: 0; opacity: 1}
}
@keyframes slideIn {
from {bottom: -300px; opacity: 0}
to {bottom: 0; opacity: 1}
}
@-webkit-keyframes fadeIn {
from {opacity: 0}
to {opacity: 1}
}
@keyframes fadeIn {
from {opacity: 0}
to {opacity: 1}
}
</style>
</head>
<body onload="resizeCanvas();draw();" onresize="updateCanvas();draw();drawChart();">
<style>
.vl {
border-left: 3px solid black;
height: 100%;
position: absolute;
left: 80%;
top: 0;
}
.data {
padding: 0%;
}
.params {
position: absolute;
left: 83%;
top: 5%;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
hr.hrr {
border: 2px solid black;
width:80%;
text-align:left;
margin-left:0
}
.input {
padding: 0.1% 2%;
display: inline-block;
}
.chart {
position: absolute;
left: 40%;
top: 78%;
}
.googleChart {
position: absolute;
left: 35%;
top: 81.5%;
}
.chooseData:active, .active {
background-color:black;
color: white;
}
.example_c {
color: #494949 !important;
text-transform: uppercase;
text-decoration: none;
background: #ffffff;
padding: 5px;
border: 2px solid #494949 !important;
display: inline-block;
transition: all 0.4s ease 0s;
}
.example_c:hover {
color: #494949 !important;
border-radius: 50px;
border-color: #494949 !important;
transition: all 0.3s ease 0s;
}
</style>
<!-- This is the dataset buttons -->
<div class="data">
<a class="example_c" id="myBtn" style="width: 2%;" target="_blank" rel="nofollow noopener">Info</a>
<button class="chooseData active" style="width: 18.5%;" id="AND">AND</button>
<button class="chooseData" style="width: 18.5%;" id="OR">OR</button>
<button class="chooseData" style="width: 18.5%;" id="flower">Iris flower dataset</button>
<button class="chooseData" style="width: 18.5%;" id="ownData">Your own data</button>
</div>
<div class="vl"></div>
<!-- infoBox and text about the website -->
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<h2>About the website and how to use it</h2>
</div>
<div class="modal-body">
<p>There are 3 loaded datasets: AND, OR and Iris flower datasets, press on the there buttons at the very top to load the datasets.</p>
<p>You can train this network with your own data, press on "Your own data" and below network diagram select input and output size.
Then write your own data into the table in the input fields and press "Add data to the table".</p>
<p>The canvas displays the neural network, in the middle of the node the bias is shown. If the weight between the nodes is positive it
will be red, the bigger the number, the more red it is. If the weight is blue then is is negative and the more blue it is, the bigger the negative is.
Also it shows which nodes and input layer(the arrows are pointing to the nodes) and which one is output layer(the arrows are pointing from the nodes).</p>
<p>You can add more or less layers in an network or nodes in a layer.</p>
<p>You have a whole set of parameters you can tweak to see which one dose what and train your model faster.</p>
<p>The table below shows inputs, expected outputs and predicted outputs.</p>
<p>made by Marijus Gudiskis [email protected]</p>
</div>
</div>
</div>
<!-- To warn mobile users that this is not for them -->
<div id="notMobile" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<h1>Not for mobile users!!!</h1>
</div>
<div class="modal-body">
<h1>This website is not made for mobile users, advance at your own risk. Use desktop to experience the full potential.</h1>
</div>
</div>
</div>
<!-- all of the parameters for the network -->
<div class="params">
<h style="font-size:30px">Parameters:</h>
<p>add layers:</p>
<button id="layersAdd">Add</button>
<label id="layerNum">2</label>
<button id="layersSub">Subtract</button>
<p>Number of nodes in a layer:</p>
<label for="layers">to which layer to add nodes:</label>
<select id="layers">
</select>
<br><br>
<button id="nodeAdd">Add</button>
<label id="nodeNum"></label>
<button id="nodeSub">Subtract</button>
<p>Select activation function:</p>
<input type="radio" id="relu" name="function" value="ReLU" checked>
<label for="relu">ReLU</label><br>
<input type="radio" id="Sigmoid" name="function" value="Sigmoid">
<label for="sigmoid">Sigmoid</label><br>
<input type="radio" id="identity" name="function" value="Identity">
<label for="identity">Identity</label><br>
<input type="radio" id="tanh" name="function" value="TanH">
<label for="tanh">TanH</label><br>
<div style="display: none" id="softhide">
<p>Use Softmax?:</p>
<input type="radio" id="yesSoft" name="Softmax" value="Yes">
<label for="yesSoft">Yes</label><br>
<input type="radio" id="noSoft" name="Softmax" value="No" checked>
<label for="noSoft">No</label><br>
</div>
<p>Use "automatic learning rate picker" and protect from gradient vanishing or exploding?:</p>
<input type="radio" id="yesAuto" name="automatic" value="Yes" checked>
<label for="yesAuto">Yes</label><br>
<input type="radio" id="noAuto" name="automatic" value="No">
<label for="noAuto">No</label><br>
<p>Learning rate: <input style="width: 75px;" type="number" id="lrRate" value="0.01"></p>
<p>Mini Batch size: <input type="number" style="width: 50px;" min="0" oninput="this.value = Math.abs(this.value)" id="miniBatch" value="4"></p>
<p>gradients momentum speed: <input type="number" style="width: 50px;" min="0" oninput="this.value = Math.abs(this.value)" id="gradMomentum" value="0.9"></p>
<p>number of iterations: <input type="number" id="numIta" min="0" oninput="this.value = Math.abs(this.value)" style="width: 100px;" value="1000"></p>
<button id="norml">Do data normalization</button>
<br>
<p> Beware of the vanishing or exploding gradient!!!</p>
<button id="backProp">Backpropagation</button>
<p>The cost of the network:</p>
<label id="costNum"></label>
</div>
<!-- canvas where the network will be displayed -->
<canvas id="snow" width="200" height="100">
Your browser does not support the canvas element. You Should use newer website.
</canvas>
<hr class="hrr">
<!-- settings for writhing your own data -->
<div id="hideInput" style="display: none">
<div class="input">
<p>Number of different inputs:</p>
<button id="inputMin">-</button>
<label id="inputNum">1</label>
<button id="inputAdd">+</button>
</div>
<div class="input">
<p>Number of different outputs:</p>
<button id="outputMin">-</button>
<label id="outputNum">1</label>
<button id="outputAdd">+</button>
</div>
</div>
<!-- table where all of the input and output will be displayed -->
<table style="width:30%" id="tables">
</table>
<!-- button to add to the table and the data arrays -->
<button id="addInfo" style="position: absolute; display: none;">Add data to the table</button>
<!-- linear graph that shows how the network is doing -->
<div class="googleChart" id="line_top_x" class="chart"></div>
<p>made by Marijus Gudiskis [email protected]</p>
<!-- displays the info box -->
<script>
var modal = document.getElementById("myModal");
var notMobile = document.getElementById("notMobile");
var btn = document.getElementById("myBtn");
var span = document.getElementsByClassName("close")[0];
var notMobileClose = document.getElementsByClassName("close")[1];
/** When the user clicks the button, open the modal */
btn.onclick = function() {
modal.style.display = "block";
}
/** When the user clicks on <span> (x), close the modal */
span.onclick = function() {
modal.style.display = "none";
}
/** When the user clicks on <span> (x), close the modal */
notMobileClose.onclick = function() {
notMobile.style.display = "none";
}
/** When the user clicks anywhere outside of the modal, close it */
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
if (event.target == notMobile) {
notMobile.style.display = "none";
}
}
/** Check if the user is using mobile device*/
var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
if (isMobile) {
notMobile.style.display = "block";
}
</script>
<!-- all of the code for running the network and its options -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="drawContent.js"></script>
<script src="neuralNetwork.js"></script>
<script src="buttons.js"></script>
<script src="googleLineChart.js"></script>
</body>
</html>