peal.sparse_dictionaries.activation_cache

Optional on-disk cache for encoder activations.

Pushing the 182k CelebA images through the semantic encoder takes ~25 minutes and produces the same 768-d vectors every time, which makes a hyperparameter sweep over the dictionary mostly a sweep over image decoding. Caching the activations turns a run into ~2 minutes of dictionary fitting plus evaluation.

Opt in with PEAL_ACT_CACHE=1. It is off by default on purpose: silently reading a stale checkpoint’s numbers has cost this project time before, and a cache that is on by default is one more way for that to happen. The key below covers the dataset identity and the encoder weights’ mtime and size, so a retrained encoder or a changed split misses rather than returns stale vectors — but only an explicit opt-in makes the trade-off visible in the command line.

Functions

cache_path

Path of the cache file for this generator/dataset combination.

enabled

Whether PEAL_ACT_CACHE is set to anything but 0/false/empty.

extract

Encode every dataset, returning one (X, Y) pair per dataset.

load_or_extract

The cached form of extract(), when PEAL_ACT_CACHE says so.