Loading Model Checkpoints

Load a PyTorch checkpoint into a model robustly when the state_dict nesting, key prefixes (model./module.), architecture, or input-channel count are uncertain. Use when a checkpoint silently loads onto random weights, load_state_dict reports missing/unexpected keys, a checkpoint comes from a different trainer (Lightning / DataParallel / raw torch), or you must infer the architecture and input channels before building the model. Picks the prefix variant by maximum key-overlap, prints missing/unexpected diagnostics, and flags the weights_only security caveat. Triggers: load a checkpoint, state_dict mismatch, missing/unexpected keys, strip module. prefix, wrong weights loaded, ckpt onto random weights.

vemodalen-x 7d8ba13 2 files · 4.5 KB Updated

File contents

vemodalen-x/VEMO_SKILLS/tree/main/skills/code/loading-model-checkpoints commit 7d8ba132aa

Frequently asked questions

npx skillmds@latest add vemodalen-x/loading-model-checkpoints