-
Notifications
You must be signed in to change notification settings - Fork 3
/
deeplearn_mnist.html
633 lines (502 loc) · 23.6 KB
/
deeplearn_mnist.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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google Analytics -->
<script async src="https://www.google-analytics.com/analytics.js"></script>
<script async src="assets/plugins/autotrack.js"></script>
<script>
window.ga = window.ga || function () {
(ga.q = ga.q || []).push(arguments)
};
ga.l = +new Date;
ga('create', 'UA-108549242-1', 'auto');
// Replace the following lines with the plugins you want to use.
// ga('require', 'eventTracker');
// ga('require', 'outboundLinkTracker');
// ga('require', 'urlChangeTracker');
// ...
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
<!-- Meta -->
<title>Deeplearnjs Practice -- MNIST Digit Recognition</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="favicon.ico">
<link href='https://fonts.googleapis.com/css?family=Roboto:400,500,400italic,300italic,300,500italic,700,700italic,900,900italic'
rel='stylesheet' type='text/css'>
<!-- Global CSS -->
<link rel="stylesheet" href="assets/plugins/bootstrap/css/bootstrap.min.css">
<!-- Plugins CSS -->
<link rel="stylesheet" href="assets/plugins/font-awesome/css/font-awesome.css">
<!-- Theme CSS -->
<link id="theme-style" rel="stylesheet" href="assets/css/styles.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.bundle.min.js"></script>
</head>
<style>
.main-wrapper {
background: #fff;
padding: 20px;
padding-right: 300px;
}
@media (max-width: 767px) {
.main-wrapper {
padding: 10px;
}
.main-wrapper .time {
position: static;
display: block;
margin-top: 5px;
}
}
.ink-panel {
/* display: flex; */
/* flex-direction: column; */
font-size: 14px;
}
.subtitle {
font-size: 15px;
font-weight: bold;
}
.title {
align-items: center;
/* border-bottom: 1px solid rgba(0, 0, 0, 0.1); */
color: black;
display: flex;
font-weight: 500;
height: 20px;
min-height: 20px;
padding-top: 20px;
padding-left: 20px;
text-transform: uppercase;
}
#dataset {
background: #fafafa;
border-right: 1px solid rgba(0, 0, 0, 0.1);
min-width: 210px;
/* width: 230px; */
/* position: relative; */
}
#dataset>div {
padding-left: 5px;
padding-right: 5px;
}
.data-stats {
margin-top: 10px;
}
/* #model-builder-container {
display: flex;
width: 100%;
} */
#model {
border-right: 1px solid rgba(0, 0, 0, 0.1);
min-width: 200px;
/* position: relative; */
}
#model>div {
padding-left: 5px;
padding-right: 5px;
}
.stat {
display: table-row;
}
.stat-label,
.stat-value {
display: table-cell;
padding: 5px 15px 5px 0;
}
#upload-download-container {
padding-top: 15px;
padding-bottom: 15px;
border-bottom: 1px solid rgba(0, 0, 0, .1);
}
.header {
border-bottom: solid .5px #666666;
height: 56px;
background: slategray;
color: #eaeaea;
z-index: 999;
font-weight: 500;
font-size: 22px;
padding-left: 12px;
line-height: 56px;
}
.train-button-container {
margin: 12px 0;
}
.model-error {
padding: 12px 0;
color: #b80000;
font-style: italic;
}
.model-error-info {
margin-left: -8px;
}
.invalid-model {
display: inline-block;
}
.inference-stats-message,
.train-stats-message {
line-height: 1.67em;
}
.button {
background-color: #a5d6a7;
}
#button-container {
width: 400px;
margin-top: 15px;
}
#inference {
/* border-right: 1px solid rgba(0, 0, 0, 0.1); */
/* flex-grow: 2; */
/* position: relative; */
min-width: 210px;
}
#inference-container {
margin-top: 15px;
}
#inference>div {
padding-left: 5px;
padding-right: 5px;
}
.inference-example {
display: flex;
justify-content: flex-start;
margin-bottom: 10px;
}
.inference-example>* {
display: table-cell;
vertical-align: middle;
}
/* ----------------------------*/
.ndarray-image-visualizer {
flex-basis: 100px;
}
.ndarray-logits-visualizer {
flex-grow: 1;
}
.logit {
font-size: 21px;
}
.logit-label {
color: #414141;
font-size: 18px;
line-height: 18px;
margin: 4px;
display: inline-block;
width: 100px;
}
.single-logit-container {
display: flex;
}
.logit-viz-outer {
flex-grow: 1;
}
.logit-viz-inner {
vertical-align: middle;
padding: 4px;
}
/* ----------------------------*/
</style>
<body onload="start()">
<!--Navigation bar-->
<div id="nav-placeholder">
</div>
<!--end of Navigation bar-->
<div class="wrapper" id="wrap">
<div class="sidebar-wrapper">
<div class="contact-container container-block">
<div class="jumbotron">
<h2>
<a href="https://deeplearnjs.org">DeeplearnJS</a> Practice</h2>
<p style='font-size:1.2em'>This demo minimally reproduces the
<a href="https://github.com/PAIR-code/deeplearnjs/blob/master/demos/model-builder/model-builder.ts">Model builder</a> example from DeeplearnJS with Rune dataset by
<a href="https://github.com/digitalheir">digitalheir</a>.
</p>
</div>
<p>Last Update: 2017-12-10</p>
<p>
<a href="https://github.com/PAIR-code/deeplearnjs/blob/master/LICENSE">DeeplearnJS's Apache License</a>
</p>
</div>
</div>
<div class="main-wrapper">
<a href="https://github.com/hma02/deeplearnjs-practice" class="github-corner" aria-label="View source on Github">
<svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;"
aria-hidden="true">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
fill="currentColor" class="octo-body"></path>
</svg>
</a>
<style>
.github-corner:hover .octo-arm {
animation: octocat-wave 560ms ease-in-out
}
@keyframes octocat-wave {
0%,
100% {
transform: rotate(0)
}
20%,
60% {
transform: rotate(-25deg)
}
40%,
80% {
transform: rotate(10deg)
}
}
@media (max-width:500px) {
.github-corner:hover .octo-arm {
animation: none
}
.github-corner .octo-arm {
animation: octocat-wave 560ms ease-in-out
}
}
</style>
<!-- <div id="model-builder-container"> -->
<div class="item row">
<div id="dataset" class="ink-panel col-md-4 col-sm-12 col-xs-12">
<div class="title">DATA</div>
<hr class="divider" />
<div class="form-group">
<label for="dataset-dropdown">Dataset</label>
<select class="form-control" id="dataset-dropdown">
<option value="MNIST">MNIST</option>
<option value="Fashion MNIST">Fashion MNIST</option>
<option value="Runes">Runes</option>
</select>
</div>
<!-- <paper-dropdown-menu no-animations label="Dataset" id="dataset-dropdown" disabled="[[!datasetDownloaded]]">
<paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedDatasetName}}" slot="dropdown-content">
<template is="dom-repeat" items="[[datasetNames]]">
<paper-item value="[[item]]" label="[[item]]">
[[item]]
</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu> -->
<div class="form-group">
<label for="model-dropdown">Model</label>
<select class="form-control" id="model-dropdown">
<option value="Convolutional">Convolutional</option>
<option value="Fully connected">Fully-Connected</option>
</select>
</div>
<!-- <paper-dropdown-menu no-animations label="Model" id="model-dropdown" disabled="[[!datasetDownloaded]]">
<paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedModelName}}" slot="dropdown-content">
<template is="dom-repeat" items="[[modelNames]]">
<paper-item value="[[item]]" label="[[item]]">
[[item]]
</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu> -->
<div class="subtitle">Hyperparameters</div>
<hr class="divider" />
<div class="form-group">
<label for="learning-rate-input" class="control-label">Learning Rate</label>
<div class="controls">
<div class="input-group">
<input name="lri" type="text" class="form-control" id="lr_input">
<div class="input-group-btn">
<button class="btn btn-default" id="buttonlr" type="submit" onclick="change_lr();">Change</button>
</div>
</div>
</div>
</div>
<!-- <paper-input no-animations label="Learning Rate" id="learning-rate-input" disabled="[[!datasetDownloaded]]" value={{learningRate}}>
</paper-input> -->
<div class="form-group">
<label for="momentum_input" class="control-label">Momentum</label>
<div class="controls">
<div class="input-group">
<input name="momi" type="text" class="form-control" id="momentum_input">
<div class="input-group-btn">
<button class="btn btn-default" id="buttonmom" type="submit" onclick="change_momentum();">Change</button>
</div>
</div>
</div>
</div>
<!-- <paper-input no-animations label="Momentum" id="momentum" hidden="[[!needMomentum]]" value={{momentum}}>
</paper-input> -->
<!-- <paper-input no-animations label="Gamma" id="gamma" hidden="[[!needGamma]]" value={{gamma}}>
</paper-input>
<paper-input no-animations label="Beta1" id="beta1" hidden="[[!needBeta1]]" value={{beta1}}>
</paper-input>
<paper-input no-animations label="Beta2" id="beta2" hidden="[[!needBeta2]]" value={{beta2}}>
</paper-input> -->
<div class="form-group">
<label for="batch-size" class="control-label">Batch Size</label>
<div class="controls">
<div class="input-group">
<input name="bsi" type="text" class="form-control" id="batch_size_input">
<div class="input-group-btn">
<button class="btn btn-default" id="buttonbs" type="submit" onclick="change_batch_size();">Change</button>
</div>
</div>
</div>
</div>
<!-- <paper-input no-animations label="Batch Size" id="batch-size" disabled="[[!datasetDownloaded]]" value={{batchSize}}>
</paper-input> -->
<div class="form-group">
<label for="optimizer-dropdown">Optimizer</label>
<select class="form-control" id="optimizer-dropdown">
<option value='sgd'>SGD</option>
<option value='momentum'>Momentum</option>
<option value='adam'>ADAM</option>
</select>
</div>
<!-- <paper-dropdown-menu no-animations label="Optimizer" id="optimizer-dropdown" disabled="[[!datasetDownloaded]]">
<paper-listbox attr-for-selected="value" class="dropdown-content" selected="{{selectedOptimizerName}}" slot="dropdown-content">
<template is="dom-repeat" items="[[optimizerNames]]">
<paper-item value="[[item]]" label="[[item]]">
[[item]]
</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu> -->
<!-- <div hidden$="[[isValid]]" class="model-error">
<div hidden$="[[!datasetDownloaded]]" ">
<paper-tooltip animation-delay="0 " fit-to-visible-bounds>
Make sure your shapes flow!" </paper-tooltip>
<paper-icon-button icon="info-outline" class="model-error-info"></paper-icon-button>
<div class="invalid-model">Invalid model</div>
</div>
</div> -->
<!-- <div class="progress-container" hidden$="[[datasetDownloaded]]">
<paper-progress indeterminate disabled="[[datasetDownloaded]]"></paper-progress>
</div> -->
<div class="form-group">
<label for="normalization-dropdown">Normalization</label>
<select class="form-control" id="normalization-dropdown">
<option value=0>[-1, 1]</option>
<option value=1>[0, 1]</option>
<option value=2>None</option>
</select>
</div>
<!-- <paper-dropdown-menu no-animations label="Normalization" id="normalization-dropdown" hidden$="[[!datasetDownloaded]]">
<paper-listbox class="dropdown-content" selected="[[selectedNormalizationOption]]" slot="dropdown-content">
<paper-item>[-1, 1]</paper-item>
<paper-item>[0, 1]</paper-item>
<paper-item>None</paper-item>
</paper-dropdown-menu> -->
<hr class="divider" />
<div class="train-stats data-stats">
<div class="subtitle">Dataset Statistics</div>
<div class="stat">
<div class="stat-label">Examples</div>
<div class="stat-value" id="statsExampleCount"></div>
</div>
<div class="stat">
<div class="stat-label">Input shape</div>
<div class="stat-value" id="statsInputShapeDisplay"></div>
</div>
<div class="stat">
<div class="stat-label">Label shape</div>
<div class="stat-value" id="statsLabelShapeDisplay"></div>
</div>
<div class="stat">
<div class="stat-label">Pixel range</div>
<div class="stat-value" id="statsInputRange"></div>
</div>
</div>
<!-- <div class="title">SAVE</div> -->
<!-- <div id="upload-download-container">
<paper-icon-button icon="file-download" id="download-model" title="Download model"></paper-icon-button>
Download model
<br>
<paper-icon-button icon="file-upload" id="upload-model" title="Upload model"></paper-icon-button>
Upload model
<paper-button raised id="upload-weights" hidden$="[[!isValid]]" style="display: none">Upload weights</paper-button>
<input type="file" id="model-file" name="model-file" style="display:none" />
<input type="file" id="weights-file" name="weights-file" style="display:none" />
</div> -->
</div>
<div id="model" class="ink-panel col-md-4 col-sm-12 col-xs-12">
<div class='hidden-lg visible-md visible-sm' style="height:50px"></div>
<div class="title">MODEL</div>
<hr class="divider" />
<div class="form-group">
<label for="environment-dropdown">Environment</label>
<select class="form-control" id="environment-dropdown">
<option value="CPU">CPU</option>
<option value="GPU">GPU</option>
</select>
</div>
<div id="layers">
<div id="input-layer" style="border:none;"></div>
<div id="hidden-layers" style="border:none;"></div>
<div id="cost-layer" style="border:none;"></div>
<div id="output-layer" style="border:none;"></div>
</div>
<!-- <div id="button-container"> -->
<!-- <paper-button class="button" raised id="add-layer">Add a layer</paper-button> -->
<!-- <br> -->
<!-- </div> -->
</div>
<div id="inference" class="ink-panel col-md-4 col-sm-12 col-xs-12">
<div class='hidden-lg visible-md visible-sm' style="height:50px"></div>
<div class="title">INFERENCE AND TRAIN STATS</div>
<hr class="divider" />
<div class="item row">
<div class="subtitle col-md-6 col-sm-6 col-xs-6">Inference</div>
<div class="col-md-6 col-sm-6 col-xs-6">
<input class="btn btn-primary btn-md" id="buttoninfer" type="submit" value="Start Inferring" onclick="ga('send', 'event', 'deeplearn_mnist', 'click', 'Start Inferring', 4);"
/>
</div>
</div>
<hr class="divider" />
<div class="inference-stats-message" id="inferencesPerSec">Inferences/sec:</div>
<div class="inference-stats-message" id="inferenceDuration">Inference duration: ms</div>
<div id="inference-container"></div>
<hr class="divider" />
<div class="item row">
<div class="subtitle col-md-6 col-sm-6 col-xs-6">Train</div>
<div class="col-md-6 col-sm-6 col-xs-6">
<input class="btn btn-primary btn-md" id="buttontrain" type="submit" value="Start Training" onclick="ga('send', 'event', 'deeplearn_mnist', 'click', 'Start Training', 5);"
/>
</div>
</div>
<hr class="divider" />
<!-- <div hidden$="[[!showTrainStats]]"> -->
<div class="train-stats-message" id="examplesPerSec">Examples/sec: </div>
<div class="train-stats-message" id="examplesTrained">Examples trained:</div>
<div class="train-stats-message" id="totalTimeSec">Total time: sec.</div>
<div class="chart-container">
<hr class="divider" />
<h5>Loss Graph</h5>
<canvas id="lossgraph"></canvas>
<hr class="divider" />
<h5>Accuracy Graph</h5>
<canvas id="accuracygraph"></canvas>
<hr class="divider" />
<h5>Examples/Sec. Graph</h5>
<canvas id="examplespersecgraph"></canvas>
</div>
<!-- </div> -->
</div>
</div>
</div>
</div>
<!-- Javascript -->
<script type="text/javascript" src="assets/plugins/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
<!-- custom js -->
<script type="text/javascript" src="assets/js/nav.js"></script>
<script src="https://unpkg.com/deeplearn@0.3.12"></script>
<!-- detect browser support -->
<script src="deeplearnjs/support.js"></script>
<script src="deeplearnjs/utils.js"></script>
<script src="deeplearnjs/mnist/model_layer.js"></script>
<script src="deeplearnjs/mnist/graph_runner.js"></script>
<script src="https://cs.stanford.edu/people/karpathy/convnetjs/build/vis.js"></script>
<script src="https://cs.stanford.edu/people/karpathy/convnetjs/build/util.js"></script>
<script type="text/javascript" src="deeplearnjs/mnist/mnist.js"></script>
</body>
</html>