|
|
@@ -37,11 +37,14 @@ __all__ = ['Dropout', 'Flatten', 'Dense', 'ClipByNorm', 'Norm', 'OneHot', 'Pad', |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class L1Regularizer(Cell): |
|
|
class L1Regularizer(Cell): |
|
|
""" |
|
|
|
|
|
|
|
|
r""" |
|
|
Apply l1 regularization to weights |
|
|
Apply l1 regularization to weights |
|
|
|
|
|
|
|
|
l1 regularization makes weights sparsity |
|
|
l1 regularization makes weights sparsity |
|
|
|
|
|
|
|
|
|
|
|
.. math:: |
|
|
|
|
|
\text{loss}=\lambda * \text{reduce_sum}(\text{abs}(\omega)) |
|
|
|
|
|
|
|
|
Note: |
|
|
Note: |
|
|
scale(regularization factor) should be a number which greater than 0 |
|
|
scale(regularization factor) should be a number which greater than 0 |
|
|
|
|
|
|
|
|
|