Skip to content
fn

load_weight_entry

→object
load_weight_entry(model: Module, weights: WeightsEnum | WeightEntry, name: str, strict: bool = True)

Download the checkpoint described by weights and load it.

Parameters

modelModule
Destination model. Its state_dict keys must match the checkpoint's (the SafeTensors file is produced by the conversion tool against this exact key layout).
The checkpoint to load — either an enum member (ResNet18Weights.IMAGENET1K_V1) or a bare WeightEntry.
name(str, keyword - only)
Cache identifier, conventionally "<model>/<tag>" so each checkpoint caches to its own directory.
strict(bool, optional, keyword - only)= True
Forwarded to Module.load_state_dict. False tolerates missing / unexpected keys (e.g. when swapping the head).

Returns

object

The _IncompatibleKeys(missing_keys, unexpected_keys) result from Module.load_state_dict.

Raises

RuntimeError
On SHA-256 verification failure, or on a key mismatch when strict=True.

Notes

SafeTensors loading goes through lucid.serialization.load_safetensors (the sanctioned external-world bridge); this module never touches numpy directly.

Used by 1