MCPcopy Create free account
hub / github.com/huggingface/transformers / load

Method load

src/transformers/modeling_utils.py:726–733  ·  view source on GitHub ↗
(module: nn.Module, prefix="")

Source from the content-addressed store, hash-verified

724 # PyTorch's `_load_from_state_dict` does not copy parameters in a module's descendants
725 # so we need to apply the function recursively.
726 def load(module: nn.Module, prefix=""):
727 local_metadata = {} if metadata is None else metadata.get(prefix[:-1], {})
728 module._load_from_state_dict(
729 state_dict, prefix, local_metadata, True, missing_keys, unexpected_keys, error_msgs,
730 )
731 for name, child in module._modules.items():
732 if child is not None:
733 load(child, prefix + name + ".")
734
735 # Make sure we are able to load base models as well as derived models (with heads)
736 start_prefix = ""

Callers 15

read_squad_examplesFunction · 0.80
load_and_cache_examplesFunction · 0.80
from_pretrainedMethod · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
from_pretrainedMethod · 0.80
get_lm_corpusFunction · 0.80

Calls 1

itemsMethod · 0.80

Tested by 3

test_pickle_tokenizerMethod · 0.64