From c27b34279c0d1c2a8f1dbceb0e154b585b5c6916 Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 13 Feb 2026 11:44:41 +0100 Subject: CNN v2 Web Tool: Unify layer terminology and add binary format spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- tools/cnn_v2_test/index.html | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'tools/cnn_v2_test') 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 = `
File Size: ${(fileSize / 1024).toFixed(2)} KB
-
Layers: ${layers.length}
+
CNN Layers: ${layers.length}
+
Static features (input) + ${layers.length} conv layers
@@ -684,11 +685,12 @@ class CNNTester { `; + // 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 += ` - + @@ -1011,9 +1013,12 @@ class CNNTester { `; + html += '
Static features (7D input) + ${this.weights.layers.length} CNN layers. Showing first 4 of 8 channels.
'; + html += '
'; 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 += ``; } html += '
'; @@ -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 -- cgit v1.2.3
${i + 1}Layer ${i + 1} ${l.inChannels}→${l.outChannels} (${l.kernelSize}×${l.kernelSize}) ${l.weightCount} ${l.min.toFixed(3)}