I have two questions about L1 regularization:


How do we backpropagate for L1 regularization? I wonder it because the term is not differentiable.


Where can I see the implementation of L1 regularization? In the following link, there is only pass.



  
      github.com
  
  
    pytorch/pytorch/blob/ecd51f8510bb1c593b0613f3dc7caf31dc29e16b/torch/nn/modules/loss.py#L39 94

def __init__(self, weight=None, size_average=True):
    super(_WeightedLoss, self).__init__(size_average)
    self.register_buffer('weight', weight)


def forward(self, input, target):
    _assert_no_grad(target)
    backend_fn = getattr(self._backend, type(self).__name__)
    return backend_fn(self.size_average, weight=self.weight)(input, target)




class L1Loss(_Loss):
r"""Creates a criterion that measures the mean absolute value of the
element-wise difference between input `x` and target `y`:


:math:`{loss}(x, y)  = 1/n \sum |x_i - y_i|`


`x` and `y` arbitrary shapes with a total of `n` elements each.


The sum operation still operates over all the elements, and divides by `n`.


The division by `n` can be avoided if one sets the constructor argument `size_average=False`