From f3c7ef8cd612f5ac908f39310c4c11566879313f Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 10 Feb 2026 17:37:01 +0100 Subject: fix: Support variable kernel sizes in CNN layer generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Training script was hardcoded to generate cnn_conv3x3_* calls regardless of actual kernel size, causing shader validation errors when layer 1 used 5×5 kernel (100 weights) but called 3×3 function (expected 36). Changes: - train_cnn.py: Generate correct conv function based on kernel_sizes[i] - cnn_conv5x5.wgsl: Add cnn_conv5x5_7to4 and cnn_conv5x5_7to1 variants - Regenerate cnn_layer.wgsl with correct function calls for [3,5,3] - Document kernel size→function mapping in HOWTO.md Co-Authored-By: Claude Sonnet 4.5 --- doc/HOWTO.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'doc/HOWTO.md') diff --git a/doc/HOWTO.md b/doc/HOWTO.md index 2c813f7..07d480b 100644 --- a/doc/HOWTO.md +++ b/doc/HOWTO.md @@ -86,12 +86,21 @@ make run_util_tests # Utility tests --- -## Training +## Training ```bash ./training/train_cnn.py --layers 3 --kernel_sizes 3,5,3 --epochs 10000 --batch_size 8 --input training/input/ --target training/output/ --checkpoint-every 1000 ``` +Generate shaders from checkpoint: +```bash +./training/train_cnn.py --export-only training/checkpoints/checkpoint_epoch_7000.pth +``` + +**Note:** Kernel sizes must match shader functions: +- 3×3 kernel → `cnn_conv3x3_7to4` (36 weights: 9 pos × 4 channels) +- 5×5 kernel → `cnn_conv5x5_7to4` (100 weights: 25 pos × 4 channels) + --- ## Timeline -- cgit v1.2.3