Tensorflow.js tf.regularizers.l1() Function
Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment.
The .regularizers.l1() function is used for L1 regularization. Moreover, it appends a name to the loss in order to rebuke enormous weights: loss += sum(l1 * abs(x)).
- config: It is an object which is optional. And under it comes l1.
- l1: It is the stated L1 regularization rate, whose by default value is 0.01. It is of type number.
Return Value: It returns Regularizer.
Example 1: In this example, we are going to see the standalone use of l1 Regularizer applied to the kernel weights matrix.
_________________________________________________________________ Layer (type) Output shape Param # ================================================================= dense_Dense52 (Dense) [null,37] 1517 ================================================================= Total params: 1517 Trainable params: 1517 Non-trainable params: 0 _________________________________________________________________
Example 2: In this example, we are going to see the standalone use of l1 Regularizer applied to the bias vector.
_________________________________________________________________ Layer (type) Output shape Param # ================================================================= dense_Dense54 (Dense) [null,2] 28 ================================================================= Total params: 28 Trainable params: 28 Non-trainable params: 0 _________________________________________________________________