Do any of the models allow for L2 Regularization? #443
-
Basic question to start a conversation. |
Beta Was this translation helpful? Give feedback.
Answered by
manujosephv
May 13, 2024
Replies: 1 comment
-
Typically, in PyTorch L2 Regularisation is applied using weight decay
Although this doesn't work like a Lasso Regression and necessarily gives you a sparse usage of features... |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mg10011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Typically, in PyTorch L2 Regularisation is applied using weight decay
Use weight_decay > 0 for L2 regularization:
optimizer = torch.optim.Adam(model.parameters(), lr=1e-4, weight_decay=1e-5)
Although this doesn't work like a Lasso Regression and necessarily gives you a sparse usage of features...