From 561d1dc446db7d1d3e02b92b43abedf1a5017850 Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 13 Feb 2026 12:32:36 +0100 Subject: CNN v2: Refactor to uniform 12D→4D architecture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Architecture changes:** - Static features (8D): p0-p3 (parametric) + uv_x, uv_y, sin(10×uv_x), bias - Input RGBD (4D): fed separately to all layers - All layers: uniform 12D→4D (4 prev/input + 8 static → 4 output) - Bias integrated in static features (bias=False in PyTorch) **Weight calculations:** - 3 layers × (12 × 3×3 × 4) = 1296 weights - f16: 2.6 KB (vs old variable arch: ~6.4 KB) **Updated files:** *Training (Python):* - train_cnn_v2.py: Uniform model, takes input_rgbd + static_features - export_cnn_v2_weights.py: Binary export for storage buffers - export_cnn_v2_shader.py: Per-layer shader export (debugging) *Shaders (WGSL):* - cnn_v2_static.wgsl: p0-p3 parametric features (mips/gradients) - cnn_v2_compute.wgsl: 12D input, 4D output, vec4 packing *Tools:* - HTML tool (cnn_v2_test): Updated for 12D→4D, layer visualization *Docs:* - CNN_V2.md: Updated architecture, training, validation sections - HOWTO.md: Reference HTML tool for validation *Removed:* - validate_cnn_v2.sh: Obsolete (used CNN v1 tool) All code consistent with bias=False (bias in static features as 1.0). handoff(Claude): CNN v2 architecture finalized and documented --- scripts/validate_cnn_v2.sh | 60 ---------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100755 scripts/validate_cnn_v2.sh (limited to 'scripts/validate_cnn_v2.sh') diff --git a/scripts/validate_cnn_v2.sh b/scripts/validate_cnn_v2.sh deleted file mode 100755 index 06a4e01..0000000 --- a/scripts/validate_cnn_v2.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# CNN v2 Validation - End-to-end pipeline - -set -e -PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -BUILD_DIR="$PROJECT_ROOT/build" -WORKSPACE="main" - -usage() { - echo "Usage: $0 [options]" - echo "Options:" - echo " -i DIR Test images (default: training/validation)" - echo " -o DIR Output (default: validation_results)" - echo " --skip-build Skip rebuild" - exit 1 -} - -[ $# -eq 0 ] && usage -CHECKPOINT="$1" -shift - -TEST_IMAGES="$PROJECT_ROOT/training/validation" -OUTPUT="$PROJECT_ROOT/validation_results" -SKIP_BUILD=false - -while [[ $# -gt 0 ]]; do - case $1 in - -i) TEST_IMAGES="$2"; shift 2 ;; - -o) OUTPUT="$2"; shift 2 ;; - --skip-build) SKIP_BUILD=true; shift ;; - -h) usage ;; - *) usage ;; - esac -done - -echo "=== CNN v2 Validation ===" -echo "Checkpoint: $CHECKPOINT" - -# Export -echo "[1/3] Exporting shaders..." -python3 "$PROJECT_ROOT/training/export_cnn_v2_shader.py" "$CHECKPOINT" \ - --output-dir "$PROJECT_ROOT/workspaces/$WORKSPACE/shaders" - -# Build -if [ "$SKIP_BUILD" = false ]; then - echo "[2/3] Building..." - cmake --build "$BUILD_DIR" -j4 --target cnn_test >/dev/null 2>&1 -fi - -# Process -echo "[3/3] Processing images..." -mkdir -p "$OUTPUT" -count=0 -for img in "$TEST_IMAGES"/*.png; do - [ -f "$img" ] || continue - name=$(basename "$img" .png) - "$BUILD_DIR/cnn_test" "$img" "$OUTPUT/${name}_output.png" 2>/dev/null && count=$((count+1)) -done - -echo "Done! Processed $count images → $OUTPUT" -- cgit v1.2.3