MCPcopy Create free account
hub / github.com/SooLab/CGFormer / init_weights

Method init_weights

bert/modeling_utils.py:447–457  ·  view source on GitHub ↗

Initialize and prunes weights if needed.

(self)

Source from the content-addressed store, hash-verified

445 return new_embeddings
446
447 def init_weights(self):
448 """ Initialize and prunes weights if needed. """
449 # Initialize weights
450 self.apply(self._init_weights)
451
452 # Prune heads if needed
453 if self.config.pruned_heads:
454 self.prune_heads(self.config.pruned_heads)
455
456 # Tie weights if needed
457 self.tie_weights()
458
459 def prune_heads(self, heads_to_prune: Dict):
460 """ Prunes heads of the base model.

Callers 9

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 2

prune_headsMethod · 0.95
tie_weightsMethod · 0.95

Tested by

no test coverage detected