Skip to content

Commit bac42cb

Browse files
author
Konstantinos Pitas
committed
Fix ini_weights
1 parent 3cfdefe commit bac42cb

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/transformers/models/dino_detr/modeling_dino_detr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,8 @@ def _init_weights(self, module):
904904
init.zeros_(module.weight[module.padding_idx])
905905
elif hasattr(module, "in_proj_weight"): # Fix for self_attn.in_proj_weight
906906
init.xavier_uniform_(module.in_proj_weight)
907+
elif hasattr(module, "in_proj_bias"): # Fix for self_attn.in_proj_bias
908+
init.xavier_uniform_(module.in_proj_bias)
907909
elif hasattr(module, "weight") and module.weight is not None: # Generic weight initialization
908910
init.normal_(module.weight, mean=0.0, std=std)
909911
if hasattr(module, "bias") and module.bias is not None:

src/transformers/models/dino_detr/modular_dino_detr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,8 @@ def _init_weights(self, module):
671671
init.zeros_(module.weight[module.padding_idx])
672672
elif hasattr(module, "in_proj_weight"): # Fix for self_attn.in_proj_weight
673673
init.xavier_uniform_(module.in_proj_weight)
674+
elif hasattr(module, "in_proj_bias"): # Fix for self_attn.in_proj_bias
675+
init.xavier_uniform_(module.in_proj_bias)
674676
elif hasattr(module, "weight") and module.weight is not None: # Generic weight initialization
675677
init.normal_(module.weight, mean=0.0, std=std)
676678
if hasattr(module, "bias") and module.bias is not None:

0 commit comments

Comments
 (0)