title: Pytorch: how to add L1 regularizer to activations?
body: <p>I would like to add the L1 regularizer to the activations output from a ReLU.
  More generally, how does one add a regularizer <strong>only to a particular layer</strong> in the network?</p>
  <hr />
  <sup>
  <p><strong>Related material:</strong></p>
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/42704283/adding-l1-l2-regularization-in-pytorch">This similar post</a> refers to adding <em>L2</em> regularization, but it appears to add the regularization penalty to <em>all</em> layers of the network.</p>
  </li>
  <li><p><code>nn.modules.loss.L1Loss()</code> seems relevant, but I do not yet understand how to use this.</p>
  </li>
  <li><p>The legacy module <a href="https://github.com/pytorch/pytorch/blob/master/torch/legacy/nn/L1Penalty.py" rel="noreferrer"><code>L1Penalty</code></a> seems relevant also, but why has it been deprecated?</p>
  </li>
  </ul>
  </sup>