mirror of
https://github.com/huggingface/transformers.git
synced 2025-08-03 03:31:05 +06:00
add comment on recursive weights loading
This commit is contained in:
parent
770b15b58c
commit
851ef592c5
@ -383,6 +383,8 @@ class PreTrainedModel(nn.Module):
|
||||
if metadata is not None:
|
||||
state_dict._metadata = metadata
|
||||
|
||||
# PyTorch's `_load_from_state_dict` does not copy parameters in a module's descendants
|
||||
# so we need to apply the function recursively.
|
||||
def load(module, prefix=''):
|
||||
local_metadata = {} if metadata is None else metadata.get(prefix[:-1], {})
|
||||
module._load_from_state_dict(
|
||||
|
Loading…
Reference in New Issue
Block a user