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)
| 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") |
no test coverage detected