Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
fix trainable and requires_grad kwargs (#2932)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Fidalgo authored and joelgrus committed Jun 7, 2019
1 parent 5f37783 commit 9a0e01f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion allennlp/models/bert_for_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def __init__(self,
else:
self.bert_model = bert_model

self.bert_model.requires_grad = trainable
for param in self.bert_model.parameters():
param.requires_grad = trainable

in_features = self.bert_model.config.hidden_size

Expand Down
3 changes: 2 additions & 1 deletion allennlp/modules/seq2vec_encoders/bert_pooler.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def __init__(self, pretrained_model: Union[str, BertModel], requires_grad: bool
model = pretrained_model

self.pooler = model.pooler
self.pooler.requires_grad = requires_grad
for param in self.pooler.parameters():
param.requires_grad = requires_grad
self._embedding_dim = model.config.hidden_size

@overrides
Expand Down

0 comments on commit 9a0e01f

Please sign in to comment.