["python","machine-learning","pytorch","loss-function","regularized"]
L1/L2 regularization in PyTorch

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.