summaryrefslogtreecommitdiff
path: root/workspaces
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-13 23:17:42 +0100
committerskal <pascal.massimino@gmail.com>2026-02-13 23:17:42 +0100
commit6fa9ccf86b0bbefb48cefae19d4162115a3d63d3 (patch)
tree529f68a33d9e4dcc8e473ed604c0bfb6f6f2704f /workspaces
parentf81a30d15e1e7db0492f45a0b9bec6aaa20ae5c2 (diff)
CNN v2: Alpha channel depth handling and layer visualization
Training changes: - Changed p3 default depth from 0.0 to 1.0 (far plane semantics) - Extract depth from target alpha channel in both datasets - Consistent alpha-as-depth across training/validation Test tool enhancements (cnn_test): - Added load_depth_from_alpha() for R32Float depth texture - Fixed bind group layout for UnfilterableFloat sampling - Added --save-intermediates with per-channel grayscale composites - Each layer saved as 4x wide PNG (p0-p3 stacked horizontally) - Global layers_composite.png for vertical layer stack overview Investigation notes: - Static features p4-p7 ARE computed and bound correctly - Sin_20_y pattern visibility difference between tools under investigation - Binary weights timestamp (Feb 13 20:36) vs HTML tool (Feb 13 22:12) - Next: Update HTML tool with canonical binary weights handoff(Claude): HTML tool weights update pending - base64 encoded canonical weights ready in /tmp/weights_b64.txt for line 392 replacement. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'workspaces')
-rw-r--r--workspaces/main/shaders/cnn_v2/cnn_v2_compute.wgsl9
-rw-r--r--workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl4
2 files changed, 8 insertions, 5 deletions
diff --git a/workspaces/main/shaders/cnn_v2/cnn_v2_compute.wgsl b/workspaces/main/shaders/cnn_v2/cnn_v2_compute.wgsl
index 6905e75..4644003 100644
--- a/workspaces/main/shaders/cnn_v2/cnn_v2_compute.wgsl
+++ b/workspaces/main/shaders/cnn_v2/cnn_v2_compute.wgsl
@@ -11,6 +11,7 @@ struct LayerParams {
weight_offset: u32, // Offset in f16 units
is_output_layer: u32, // 1 if final layer (sigmoid), 0 otherwise (relu)
blend_amount: f32, // [0,1] blend with original
+ is_layer_0: u32, // 1 if first layer (clamp [0,1]), 0 otherwise
}
@group(0) @binding(0) var static_features: texture_2d<u32>; // 8D static features (p0-p3 + spatial)
@@ -120,11 +121,13 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
}
}
- // Activation
+ // Activation (matches train_cnn_v2.py)
if (is_output) {
- output[c] = clamp(sum, 0.0, 1.0);
+ output[c] = clamp(sum, 0.0, 1.0); // Output layer: clamp [0,1]
+ } else if (params.is_layer_0 != 0u) {
+ output[c] = clamp(sum, 0.0, 1.0); // Layer 0: clamp [0,1]
} else {
- output[c] = max(0.0, sum); // ReLU
+ output[c] = max(0.0, sum); // Middle layers: ReLU
}
}
diff --git a/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl b/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl
index 35068a2..7b08132 100644
--- a/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl
+++ b/workspaces/main/shaders/cnn_v2/cnn_v2_static.wgsl
@@ -48,9 +48,9 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
let p2 = rgba.b;
let p3 = textureLoad(depth_tex, coord, 0).r;
- // UV coordinates (normalized [0,1], bottom-left origin)
+ // UV coordinates (normalized [0,1], top-left origin - matches training)
let uv_x = f32(coord.x) / f32(dims.x);
- let uv_y = 1.0 - (f32(coord.y) / f32(dims.y));
+ let uv_y = f32(coord.y) / f32(dims.y);
// Multi-frequency position encoding
let sin20_y = sin(20.0 * uv_y);