forked from dsgiitr/VisualML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
274 lines (243 loc) · 9.85 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
<html>
<head>
<title>VisualML | CNN</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="tfjs-examples.css" />
<link rel="shortcut icon" href="../img/favicon.ico" type="image/x-icon">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<style>
#train {
margin-top: 10px;
}
label {
display: inline-block;
width: 250px;
padding: 6px 0 6px 0;
}
.canvases {
display: inline-block;
}
.prediction-canvas {
width: 100px;
}
.pred {
font-size: 20px;
line-height: 25px;
width: 100px;
}
.pred-correct {
background-color: #00cf1c;
}
.pred-incorrect {
background-color: red;
}
.pred-container {
display: inline-block;
width: 100px;
margin: 10px;
}
.btn:hover {
background-color: #035aa6 !important;
}
#container1 {
height: 100%;
width: 100%;
display: flex;
}
#parameters {
width: 35%;
}
#images {
width: 65%;
}
#container2 {
height: 100%;
width: 100%;
display: flex;
}
#board {
width: 50%;
}
#chart {
width: 50%;
}
</style>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
</head>
<body>
<div style="background-color: #eafdf8;">
<div class="tfjs-example-container">
<section class="title-area">
<h1 style="
font-family: Roboto, sans-serif;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
font-size: 3rem;
line-height: 3.125rem;
font-weight: 400;
letter-spacing: normal;
text-decoration: inherit;
text-transform: inherit;
">
Train a Convolutional Neural Network online!
</h1>
<p class="subtitle" style="
font-family: Roboto, sans-serif;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
font-size: 1.25rem;
line-height: 2rem;
margin-top: 0.5em;
font-weight: 500;
letter-spacing: 0.0125em;
text-decoration: inherit;
text-transform: inherit;
">
Train a CNN to recognize handwritten digits from the MNIST database using the tf.layers api.
</p>
</section>
<section>
<p class="section-head">
Description
</p>
<p>
This examples lets you train a handwritten digit recognizer using either a Convolutional Neural Network (also known as a ConvNet or CNN) The CNN contains 8 layers in total. We use the softmax function as the activation for the output layer as it creates
a probability distribution over our 10 classes so their output values sum to 1. Go train that model!
</p>
<p>The MNIST dataset is used as training data.</p>
</section>
<section>
<p class="section-head">Training Parameters</p>
<div id="container1">
<div id="parameters">
<div>
<label style="font-size: large; font-weight: 500;">
No. of training epochs:
</label>
<input id="train-epochs" value="3" />
</div>
<div>
<label style="font-size: large; font-weight: 500;">
Optimizer:
</label>
<select id="optimizer">
<option>
Adam
</option>
<option>
RMSprop
</option>
<option>
SGD
</option>
</select>
</div>
<div>
<label style="font-size: large; font-weight: 500;">
Learning Rate:
</label>
<input id="learning-rate" value="0.003" />
</div>
<div>
<label style="font-size: large; font-weight: 500;">
Batch Size:
</label>
<input id="batch-size" value="640" />
</div>
<button id="train" class="btn btn-dark">
Load Data and Train Model
</button>
</div>
<div id="images">
</div>
</div>
</section>
<section>
<p class="section-head">Training Progress</p>
<p id="status"></p>
<p id="message"></p>
<div id="stats">
<div class="canvases">
<label id="loss-label" style="font-size: large; font-weight: 200;"></label>
<div id="loss-canvas"></div>
</div>
<div class="canvases">
<label id="accuracy-label" style="font-size: large; font-weight: 200;"></label>
<div id="accuracy-canvas"></div>
</div>
</div>
</section>
<section>
<p class="section-head" id="heading">Test Your Model</p>
<p>
Feel free to draw digits on the small blackboard there and get your model to predict the numbers!
</p>
<p style="font-weight: bold;">
Note: Press ` to toggle the bar chart window.
</p>
<div id="container2">
<div id="board">
<div id="canvas_box" class="canvas-box" style="margin-left: 20em; margin-bottom: 1em;">
</div>
<button id="clear-button" class="btn btn-dark" marginTop="1em" marginBottom="1em" style="background-color: crimson; margin-left: 19em; width: 9.5em;">
Clear
</button>
<button id="predict-button" class="btn btn-dark" marginTop="1em" marginBottom="1em" style="background-color: #00cf1c; margin-left: 10px; width: 9.5em;">
Predict
</button>
</div>
<div id="chart">
<canvas id="myChart" width="600" height="300"></canvas>
</div>
</div>
</section>
<section>
<p class="section-head" id="heading">Visualise Layers</p>
<p>
Now, you can visualise the layers by seeing the transformation done on image by each layer.
</p>
<div>
<p id="log" marginTop="1em"></p>
</div>
<p style="padding-top: 0.5em;">
Layer-1 is a conv2D layer with 8 filters.
</p>
<div id="Layer0"></div>
<p style="padding-top: 0.5em;">
Layer-2 is a downsampling layer that downsamples the input by a factor of 2 in both dimensions.
</p>
<div id="Layer1"></div>
<p style="padding-top: 0.5em;">
Layer-3 is a conv2D layer with 16 filters.
</p>
<div id="Layer2"></div>
<p style="padding-top: 0.5em;">
Layer-4 is a downsampling layer that downsamples the input by a factor of 2 in both dimensions.
</p>
<div id="Layer3"></div>
<p style="padding-top: 0.5em;">
Layer-5 is a conv2D layer with 32 filters.
</p>
<div id="Layer4"></div>
<p style="padding-top: 0.5em;">Layer-6 is a flattening layer</p>
<div id="Layer5"></div>
<div id="Spacing1" marginTop="1em"></div>
<p style="padding-top: 0.5em;">
Layer-7 is a dense layer with 10 units.
</p>
<div id="Layer6"></div>
<div id="Spacing" marginTop="1em"></div>
<p style="padding-top: 0.5em;">
Layer-8 is also a dense layer, but it has 10 units. One for each type of output.
</p>
<div id="Layer7"></div>
<div id="Spacing2" marginTop="1em"></div>
</section>
<p>You can also check out a <a href="https://garg-doppler.github.io/MNIST-CNN/" target="_blank">3D model</a> of this CNN, and play with it.</p>
</div>
</div>
<script src="index.js"></script>
</body>
</html>