mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Better check in initialize_weights
(#38382)
* Update modeling_utils.py * CIs * CIs
This commit is contained in:
parent
eb74cf977b
commit
8b03c8eaf2
@ -2658,7 +2658,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, PushToHubMixin, PeftAdapterMi
|
||||
def smart_apply(self, fn):
|
||||
for module in self.children():
|
||||
# We found a sub-model: recursively dispatch its own init function now!
|
||||
if hasattr(module, "_init_weights"):
|
||||
if isinstance(module, PreTrainedModel):
|
||||
module.smart_apply(module._initialize_weights)
|
||||
else:
|
||||
module.smart_apply(fn)
|
||||
|
Loading…
Reference in New Issue
Block a user