Commit Graph
6 Commits
Author SHA1 Message Date
jensandClaude Sonnet 4.6 d4d3d33931 [bugfix] - fix L1/L2 scaling: move regularisation out of grad_compute into state_adjust
Regularisation terms (L1, L2, weight_decay) were being divided by mini_batch_size
in state_adjust along with the CD gradient. The CD gradient is a batch sum so
1/N normalisation is correct; regularisation penalties are per-weight and
batch-size independent. Separating them makes l1_lambda/l2_lambda directly
interpretable regardless of batch size.

Also adds --l1_lambda CLI arg to test_faces_sub_image.py and sets num_epochs=1000.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 19:58:44 +02:00
jensandClaude Sonnet 4.6 e0dcac5c82 [normalize] - simplify and harden normalize(); remove duplicate in load_image_patches
image.py: replace repeat/reshape with keepdims=True; guard std < 1e-8 to
prevent NaN on constant patches (previously relied on call-site pre-filtering).
test_faces_sub_image.py: load_image_patches now calls normalize() directly
instead of duplicating the per-sample normalization logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 18:22:19 +02:00
jensandClaude Sonnet 4.6 07fc7dc607 [faces_sub_image] - add --grayscale CLI flag for single-channel mode
GRAYSCALE flag drives N_CH (1 or 3) and N_VIS (1024 or 3072) at runtime.
_img_to_chw() handles BGR→gray or BGR→RGB conversion.
All visualisation functions use cmap='gray' when GRAYSCALE is set.
Separate model name (faces_sub_image_gray) keeps weights isolated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 16:07:08 +02:00
jensandClaude Sonnet 4.6 fc10fab627 [faces_sub_image] - add overlap patch extraction and boundary blending reconstruction
Replace non-overlapping stride=32 with stride=16 (50% overlap) throughout.
Add assemble_overlapping() which accumulates reconstructed patches into a
float buffer and averages contributions per pixel, eliminating blocking artefacts.
Update load_image_patches to return nx_steps/ny_steps for correct reassembly.
Add start parameter to load_patches for held-out test image selection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 15:33:49 +02:00
jensandClaude Sonnet 4.6 feaf96417a [faces_sub_image] - add --load_model and --do_train CLI args
Reconstruction always runs. Default: load saved weights, skip training.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 15:25:22 +02:00
jensandClaude Sonnet 4.6 441354088f [faces_sub_image] - add GB-RBM autoencoder test on Caltech WebFaces using SubImage ROIs
Extracts non-overlapping 32x32 RGB patches from face images using SubImage,
trains a GB-RBM (3072 visible, 128 hidden), and visualises learned filters,
patch reconstructions, and full image reconstruction.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 15:20:21 +02:00