Use precomputed exposure embeddings

This commit is contained in:
2026-07-09 16:49:49 +08:00
parent 552e09aa01
commit e439c3c98c
7 changed files with 311 additions and 281 deletions

View File

@@ -68,9 +68,8 @@ python train_exposure_autoencoder.py \
--val_eid_file ukb_val_eid.csv
```
The best checkpoint contains both `model_state_dict`, an `encoder_state_dict`
compatible with the default gated `TimesNetExposureEncoder`, and the channel
normalization statistics needed when the encoder is attached to DeepHealth.
The best checkpoint contains the encoder and normalization statistics needed
to generate fixed exposure embeddings.
Multi-GPU pretraining follows the main trainer interface: add
`--data_parallel --gpu_ids 0,1,2,3`.
For efficient multi-GPU training, launch one process per GPU with DDP:
@@ -84,13 +83,21 @@ torchrun --standalone --nproc_per_node=4 train_exposure_autoencoder.py \
In DDP mode, `--batch_size` is the global batch size and must be divisible by
the number of processes.
The end-to-end next-step trainer supports the same DDP launch pattern:
Encode every cached exposure window once:
```bash
python encode_exposure_cache.py \
--exposure_cache_dir ukb_exposure_cache \
--checkpoint runs/exposure_ae_RUN/best.pt
```
The next-step trainer reads `exposure_embeddings.npy` directly and does not
run TimesNet:
```bash
torchrun --standalone --nproc_per_node=4 train_next_step.py \
--exposure_cache_dir ukb_exposure_cache \
--batch_size 128 \
--d_model 64
--batch_size 128
```
Training-channel statistics are cached at
`<exposure_cache_dir>/train_channel_stats.npz`; use