Skip to content

Instantly share code, notes, and snippets.

@sobamchan
Last active November 10, 2019 12:34
Show Gist options
  • Save sobamchan/cad027ad2449c9bc1056b96235d0cc94 to your computer and use it in GitHub Desktop.
Save sobamchan/cad027ad2449c9bc1056b96235d0cc94 to your computer and use it in GitHub Desktop.
pl-bert
def configure_optimizers(self):
param_optimizer = list(self.model.named_parameters())
no_decay = ["bias", "gamma", "beta"]
optimizer_grouped_parameters = [
{
"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 = AdamW(
optimizer_grouped_parameters,
lr=2e-5,
)
return optimizer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment