diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-13 11:44:41 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-13 11:44:41 +0100 |
| commit | c27b34279c0d1c2a8f1dbceb0e154b585b5c6916 (patch) | |
| tree | 5918fbaadad369ec8213df1682919ebaf9f57b56 /tools/cnn_v2_test | |
| parent | 6ca832296a74b3a3342320cf4edaa368ebc56afe (diff) | |
CNN v2 Web Tool: Unify layer terminology and add binary format spec
- Rename 'Static (L0)' → 'Static' (clearer, less confusing)
- Update channel labels: 'R/G/B/D' → 'Ch0 (R)/Ch1 (G)/Ch2 (B)/Ch3 (D)'
- Add 'Layer' prefix in weights table for consistency
- Document layer indexing: Static + Layer 1,2,3... (UI) ↔ weights.layers[0,1,2...]
- Add explanatory notes about 7D input and 4-of-8 channel display
- Create doc/CNN_V2_BINARY_FORMAT.md with complete .bin specification
- Cross-reference spec in CNN_V2.md and CNN_V2_WEB_TOOL.md
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'tools/cnn_v2_test')
| -rw-r--r-- | tools/cnn_v2_test/index.html | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/tools/cnn_v2_test/index.html b/tools/cnn_v2_test/index.html index bfc91c5..9ce3d8c 100644 --- a/tools/cnn_v2_test/index.html +++ b/tools/cnn_v2_test/index.html @@ -669,7 +669,8 @@ class CNNTester { let html = ` <div style="margin-bottom: 12px;"> <div><strong>File Size:</strong> ${(fileSize / 1024).toFixed(2)} KB</div> - <div><strong>Layers:</strong> ${layers.length}</div> + <div><strong>CNN Layers:</strong> ${layers.length}</div> + <div style="font-size: 9px; color: #808080; margin-top: 4px;">Static features (input) + ${layers.length} conv layers</div> </div> <table> <thead> @@ -684,11 +685,12 @@ class CNNTester { <tbody> `; + // Display layers as "Layer 1", "Layer 2", etc. (matching visualization button labels) for (let i = 0; i < layers.length; i++) { const l = layers[i]; html += ` <tr> - <td>${i + 1}</td> + <td>Layer ${i + 1}</td> <td>${l.inChannels}→${l.outChannels} (${l.kernelSize}×${l.kernelSize})</td> <td>${l.weightCount}</td> <td>${l.min.toFixed(3)}</td> @@ -1011,9 +1013,12 @@ class CNNTester { </div> `; + html += '<div style="font-size: 9px; color: #808080; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid #404040;">Static features (7D input) + ${this.weights.layers.length} CNN layers. Showing first 4 of 8 channels.</div>'; + html += '<div class="layer-buttons">'; for (let i = 0; i < this.layerOutputs.length; i++) { - const label = i === 0 ? 'Static (L0)' : `Layer ${i}`; + // Visualization layers: Static features (i=0), CNN Layer 1 (i=1), CNN Layer 2 (i=2), ... + const label = i === 0 ? 'Static' : `Layer ${i}`; html += `<button onclick="tester.visualizeLayer(${i})" id="layerBtn${i}">${label}</button>`; } html += '</div>'; @@ -1084,7 +1089,10 @@ class CNNTester { // Check mode if (this.vizMode === 'weights' && layerIdx > 0) { - this.visualizeWeights(layerIdx - 1); // Layer 1 → weights.layers[0] + // Map visualization layer to weight array index + // Visualization Layer 1 (layerIdx=1) → weights.layers[0] (CNN Layer 1 weights) + // Visualization Layer 2 (layerIdx=2) → weights.layers[1] (CNN Layer 2 weights) + this.visualizeWeights(layerIdx - 1); return; } @@ -1108,9 +1116,11 @@ class CNNTester { this.log(`Visualizing ${layerName} activations (${width}×${height})`); // Update channel labels based on layer type + // Static features: 8 channels total (R,G,B,D,UV_X,UV_Y,sin,bias), showing first 4 + // CNN layers: Up to 8 channels per layer, showing first 4 const channelLabels = layerIdx === 0 - ? ['R', 'G', 'B', 'D'] // Static features: RGBA (R,G,B,Depth,UV_X,UV_Y,sin,bias) - : ['Ch0', 'Ch1', 'Ch2', 'Ch3']; // CNN layers + ? ['Ch0 (R)', 'Ch1 (G)', 'Ch2 (B)', 'Ch3 (D)'] + : ['Ch0', 'Ch1', 'Ch2', 'Ch3']; for (let c = 0; c < 4; c++) { const label = document.getElementById(`channelLabel${c}`); @@ -1201,14 +1211,17 @@ class CNNTester { } visualizeWeights(cnnLayerIdx) { + // cnnLayerIdx is index into weights.layers[] array + // Display as "Layer N" where N = cnnLayerIdx + 1 (e.g., weights.layers[0] = Layer 1) const layer = this.weights.layers[cnnLayerIdx]; if (!layer) { - this.log(`Layer ${cnnLayerIdx} not found`, 'error'); + this.log(`CNN Layer ${cnnLayerIdx + 1} not found`, 'error'); return; } const { kernelSize, inChannels, outChannels, weightOffset, min, max } = layer; - this.log(`Visualizing Layer ${cnnLayerIdx + 1} weights: ${inChannels}→${outChannels}, ${kernelSize}×${kernelSize}, offset=${weightOffset}`); + const displayLayerNum = cnnLayerIdx + 1; + this.log(`Visualizing Layer ${displayLayerNum} weights: ${inChannels}→${outChannels}, ${kernelSize}×${kernelSize}, offset=${weightOffset}`); this.log(`Weight range: [${min.toFixed(3)}, ${max.toFixed(3)}]`); // Update channel labels to show output channels |
