Skip to content

Commit

Permalink
Merge pull request huggingface#32 from xiaoda99/master
Browse files Browse the repository at this point in the history
Fix ineffective no_decay bug when using BERTAdam
  • Loading branch information
thomwolf authored Nov 20, 2018
2 parents 51134ad + fb12491 commit 18c4841
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/run_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ def main():
param_optimizer = list(model.named_parameters())
no_decay = ['bias', 'gamma', 'beta']
optimizer_grouped_parameters = [
{'params': [p for n, p in param_optimizer if n not in no_decay], 'weight_decay_rate': 0.01},
{'params': [p for n, p in param_optimizer if n in no_decay], 'weight_decay_rate': 0.0}
{'params': [p for n, p in param_optimizer if not any(nd in n for nd in no_decay)], 'weight_decay_rate': 0.01},
{'params': [p for n, p in param_optimizer if any(nd in n for nd in no_decay)], 'weight_decay_rate': 0.0}
]
optimizer = BertAdam(optimizer_grouped_parameters,
lr=args.learning_rate,
Expand Down

0 comments on commit 18c4841

Please sign in to comment.