Commit Graph
15 Commits
Author SHA1 Message Date
jensandClaude Sonnet 4.6 1954064a54 [refactor] move rbm.model → model.model
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-02 08:55:16 +02:00
jensandClaude Sonnet 4.6 a07698497d [refactor] SubImage → SubImageExtract, add SubImageCombine
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-02 08:20:38 +02:00
jensandClaude Sonnet 4.6 b0d370a56b [refactor] move rbm.image → image.sub_image
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-02 08:01:51 +02:00
jensandClaude Sonnet 4.6 4a915f165a [context33] - increase momentum 0.5→0.7; run outputs 99% recon, 88% next-step
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 20:06:20 +02:00
jensandClaude Sonnet 4.6 37c6e33948 [CheckpointStatus] - add checkpoint status handler; Model.train() accepts status param
status.py: add CheckpointStatus(save_fn, update_interval) — prints progress
and calls save_fn at every report interval to persist model state mid-training.
model.py: Model.train() now accepts an optional Status instance; defaults to
plain Status() if none provided.
test_faces_sub_image.py: use CheckpointStatus(model.save) during training.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 22:42:01 +02:00
jensandClaude Sonnet 4.6 2f9fe1b66b [bugfix] - support large CPU-side datasets; fix numpy/CuPy interop
train.py: add _to_gpu() helper; convert mini-batches from CPU numpy to GPU
CuPy on the fly so large datasets can stay in RAM. Use numpy permutation for
numpy batches during shuffle. Limit status err_rms to first 5000 samples to
avoid GPU OOM on status checks.

model.py: replace np.copy() with np.array() — cupy.copy() does not convert
numpy arrays to CuPy; cupy.array() does. Fixes entity.forward() crash after
training when batch was passed as numpy.

test_faces_sub_image.py: load_patches normalizes on CPU and returns numpy,
avoiding multi-copy GPU OOM for large datasets (500 images ≈ 1.4 GB).
show_reconstructions converts numpy patches to CuPy before inference.
Add --n_images CLI arg.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 22:26:06 +02:00
jensandClaude Sonnet 4.6 68b376657c [faces_sub_image] - add --mini_batch_size CLI arg
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 21:13:25 +02:00
jensandClaude Sonnet 4.6 96f271f160 [faces_sub_image] - add --num_epochs CLI arg
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 20:38:33 +02:00
jensandClaude Sonnet 4.6 edeeb1773b [README] - update faces_sub_image entry; bump N_HID to 256
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 20:18:46 +02:00
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