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

Method _prune_heads

bert/modeling_bert.py:660–666  ·  view source on GitHub ↗

Prunes heads of the model. heads_to_prune: dict of {layer_num: list of heads to prune in this layer} See base class PreTrainedModel

(self, heads_to_prune)

Source from the content-addressed store, hash-verified

658 self.embeddings.word_embeddings = value
659
660 def _prune_heads(self, heads_to_prune):
661 """ Prunes heads of the model.
662 heads_to_prune: dict of {layer_num: list of heads to prune in this layer}
663 See base class PreTrainedModel
664 """
665 for layer, heads in heads_to_prune.items():
666 self.encoder.layer[layer].attention.prune_heads(heads)
667
668 @add_start_docstrings_to_callable(BERT_INPUTS_DOCSTRING.format("(batch_size, sequence_length)"))
669 @add_code_sample_docstrings(tokenizer_class=_TOKENIZER_FOR_DOC, checkpoint="bert-base-uncased")

Callers 1

prune_headsMethod · 0.80

Calls 2

itemsMethod · 0.80
prune_headsMethod · 0.45

Tested by

no test coverage detected