How do I add L1/L2 regularization in PyTorch without manually computing it?
Advertisement
Answer
See the documentation. Add a weight_decay
parameter to the optimizer for L2 regularization.
How do I add L1/L2 regularization in PyTorch without manually computing it?
See the documentation. Add a weight_decay
parameter to the optimizer for L2 regularization.