-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
290 lines (267 loc) · 12.7 KB
/
index.html
File metadata and controls
290 lines (267 loc) · 12.7 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TopoNets Visualizer</title>
<link rel="icon" type="image/png" href="assets/toponets_icon.png">
<script type="module" crossorigin src="./assets/main.js"></script>
<link rel="stylesheet" crossorigin href="./assets/main.css">
</head>
<body>
<!-- 2D Grid Overlay -->
<div id="overlay2d" class="overlay-2d">
<div class="container">
<div id="gridContainer" class="grid-container"></div>
</div>
</div>
<!-- Reset Button -->
<div id="resetButtonContainer" class="reset-button-container">
<button id="resetBtn">✖</button>
</div>
<!-- Prediction Chart Overlay -->
<div id="predictionOverlay" class="prediction-overlay">
<div class="prediction-container">
<div id="predictionChart"></div>
</div>
<div id="networkInfoPanel" class="network-info-panel"></div>
</div>
<!-- Instructions Overlay -->
<div id="instructionsOverlay" class="instructions-overlay">
<div class="instructions-container">
<div class="instructions-content">
<p><strong>Draw:</strong> Click and drag on the grid (Right-click to erase)</p>
<p><strong>3D Controls:</strong> • Left button + drag = rotate • Right button + drag = move • Scroll wheel = zoom</p>
</div>
</div>
</div>
<!-- Mobile Instructions Overlay -->
<div id="mobileInstructionsOverlay" class="mobile-instructions-overlay">
<div class="mobile-instructions-content">
<div class="mobile-instructions-title">Touch Controls</div>
<ul class="mobile-gesture-list">
<li><strong>Draw:</strong> Tap and drag on the grid</li>
<li><strong>Rotate:</strong> Drag with one finger</li>
<li><strong>Move:</strong> Move with two fingers</li>
<li><strong>Zoom:</strong> Pinch or spread fingers</li>
</ul>
</div>
</div>
<!-- Floating Controls -->
<div class="floating-controls">
<button
id="advancedSettingsButton"
class="floating-button advanced-settings-button"
aria-haspopup="dialog"
aria-controls="advancedSettingsModal"
type="button"
>
<span>⚙</span>
</button>
<button
id="infoButton"
class="floating-button info-button"
aria-haspopup="dialog"
aria-controls="infoModal"
type="button"
>
<span>i</span>
</button>
</div>
<!-- MNIST Sample Images - Bottom Edge -->
<div id="mnistImagesContainer" class="mnist-images-container"></div>
<!-- Neuron Detail Panel -->
<div id="neuronDetailPanel" class="neuron-detail-panel" aria-live="polite"></div>
<!-- Training Timeline Slider -->
<div id="timelineOverlay" class="timeline-overlay hidden">
<div class="timeline-container">
<div class="timeline-header">
<span class="timeline-title">Training Progress</span>
<span id="timelineSummary" class="timeline-summary"></span>
</div>
<input
id="timelineSlider"
class="timeline-slider"
type="range"
min="0"
value="0"
step="1"
disabled
aria-label="Training Progress"
>
<div class="timeline-meta">
<span id="timelineLabel" class="timeline-label"></span>
<span id="timelineMetrics" class="timeline-metrics timeline-metrics--empty"></span>
</div>
</div>
</div>
<a
href="https://toponets.github.io/"
class="github-link"
target="_blank"
rel="noopener noreferrer"
style="font-size: 1.5em;"
>
Paper + Code + Models: https://toponets.github.io/
</a>
<!-- Info Modal -->
<div id="infoModal" class="info-modal">
<div class="info-modal-content">
<div class="info-modal-header">
<h3>MNIST Digit Classification – Visualization of Inference</h3>
<button id="closeInfoModal" class="close-modal-btn">×</button>
</div>
<div class="info-modal-body">
<p><strong>Interactive Visualization of a Neural Network</strong></p>
<p>This application shows a compact Multi-Layer Perceptron (MLP) trained on MNIST. Draw a digit and observe how activations propagate through all fully connected layers in real time.</p>
<h4>How it works:</h4>
<ul>
<li><strong>Draw:</strong> Click and drag in the 2D grid (top left) to sketch a digit</li>
<li><strong>Observe:</strong> Watch your sketch move through the network layers in 3D space</li>
<li><strong>Prediction:</strong> Check the probability for each digit (0–9) in the chart (top right)</li>
</ul>
<h4>Network Architecture (default export):</h4>
<ul>
<li><strong>Input Layer:</strong> 28×28 pixel grid (your drawing)</li>
<li><strong>Dense Layer 1:</strong> 784 → 64 neurons with ReLU</li>
<li><strong>Dense Layer 2:</strong> 64 → 32 neurons with ReLU</li>
<li><strong>Output Layer:</strong> 32 → 10 logits → Softmax probabilities</li>
</ul>
<h4>3D Controls:</h4>
<ul>
<li><strong>Rotate:</strong> Hold left mouse button and drag</li>
<li><strong>Move:</strong> Hold right mouse button and drag</li>
<li><strong>Zoom:</strong> Use the mouse wheel</li>
</ul>
<h4>Color Coding:</h4>
<ul>
<li><strong>Nodes:</strong> Color represents activation strength (dark blues for low/negative values, bright coral for strong positive activations)</li>
<li><strong>Connections:</strong> Warm colors indicate strong positive contributions, cool tones indicate negative influences, muted lines are near zero.</li>
</ul>
<h4>Train your own model:</h4>
<ul>
<li>Run <code>python training/mlp_train.py</code> to train the MLP (includes Apple Metal acceleration if available).</li>
<li>The script writes <code>exports/mlp_weights.json</code>, which the visualizer loads at startup.</li>
<li>Change hidden neurons, epochs, or export paths using the CLI options documented in <code>training/mlp_train.py</code>.</li>
</ul>
<h4>Real-time Features:</h4>
<ul>
<li><strong>Layer Activations:</strong> Spheres represent activations per neuron with color-coded strength.</li>
<li><strong>Key Connections:</strong> Each target neuron highlights its strongest input weights for readability.</li>
<li><strong>Live Probabilities:</strong> The bar chart updates logits → softmax values in real time.</li>
</ul>
<p>The network is intentionally compact for smooth real-time rendering. You can retrain with other layer sizes—just keep the architecture lightweight for a responsive 3D view.</p>
</div>
</div>
</div>
<!-- Advanced Settings Modal -->
<div id="advancedSettingsModal" class="advanced-modal" role="dialog" aria-modal="true" aria-labelledby="advancedSettingsTitle">
<div class="advanced-modal-content">
<div class="advanced-modal-header">
<h3 id="advancedSettingsTitle">Advanced Settings</h3>
<button id="closeAdvancedSettings" class="close-modal-btn" type="button">×</button>
</div>
<div class="advanced-modal-body">
<div class="advanced-control">
<label for="connectionLimitSlider" class="advanced-label">
Maximum Connections per Neuron
</label>
<div class="advanced-slider">
<input
id="connectionLimitSlider"
type="range"
min="1"
max="64"
step="1"
value="24"
>
<span id="connectionLimitValue" class="advanced-value">24</span>
</div>
<p class="advanced-hint">
Controls how many of the strongest incoming weights per target neuron are displayed simultaneously; high values may slow down rendering.
</p>
</div>
<div class="advanced-control">
<label for="connectionThresholdSlider" class="advanced-label">
Hide Weak Connections
</label>
<div class="advanced-slider">
<input
id="connectionThresholdSlider"
type="range"
min="0"
max="0.5"
step="0.0005"
value="0"
>
<span id="connectionThresholdValue" class="advanced-value">0.0000</span>
</div>
<p class="advanced-hint">
Hides connections with low absolute weights; 0 shows all connections.
</p>
</div>
<div class="advanced-control">
<label for="connectionThicknessSlider" class="advanced-label">
Connection Thickness
</label>
<div class="advanced-slider">
<input
id="connectionThicknessSlider"
type="range"
min="0.001"
max="0.03"
step="0.001"
>
<span id="connectionThicknessValue" class="advanced-value"></span>
</div>
<p class="advanced-hint">
Adjusts the radius of connection cylinders; higher values make all lines thicker.
</p>
</div>
<div class="advanced-control">
<label for="brushThicknessSlider" class="advanced-label">
Brush Thickness
</label>
<div class="advanced-slider">
<input
id="brushThicknessSlider"
type="range"
min="0.4"
max="4"
step="0.1"
value="1.4"
>
<span id="brushThicknessValue" class="advanced-value">1.4</span>
</div>
<p class="advanced-hint">
Smaller values produce finer strokes; larger values fill the grid faster.
</p>
</div>
<div class="advanced-control">
<label for="brushStrengthSlider" class="advanced-label">
Brush Intensity
</label>
<div class="advanced-slider">
<input
id="brushStrengthSlider"
type="range"
min="0.3"
max="1"
step="0.05"
value="0.95"
>
<span id="brushStrengthValue" class="advanced-value">95%</span>
</div>
<p class="advanced-hint">
Determines how strongly a brush stroke increases pixel brightness.
</p>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://unpkg.com/three@0.128.0/examples/js/controls/OrbitControls.js"></script>
<!-- 100% privacy-first analytics -->
<script data-collect-dnt="true" async src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
</body>
</html>