Class L1L2
java.lang.Object
org.tensorflow.framework.regularizers.AbstractRegularizer
org.tensorflow.framework.regularizers.L1L2
- All Implemented Interfaces:
Regularizer
A regularizer that applies both L1 and L2 regularization penalties.
The L1 regularization penalty is computed as:
loss = l1 * reduceSum(abs(x))
The L2 regularization penalty is computed as
loss = l2 * reduceSum(square(x))
-
Field Summary
Fields inherited from class AbstractRegularizer
DEFAULT_REGULARIZATION_PENALTY -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class AbstractRegularizer
asLoss, getName
-
Constructor Details
-
L1L2
public L1L2()Creates an L1L2 regularizer with no l1 or l2 penalty with zero penalty -
L1L2
public L1L2(float l1, float l2) Creates an L1L2 regularizer- Parameters:
l1- L1 regularization factor, if null it is set to 0.l2- L2 regularization factor, if null it is set to 0.- Throws:
IllegalArgumentException- if the l1 or l2 regularization factor isFloat.isNaN(float)ofFloat.isInfinite(float)
-
L1L2
Creates an L1L2 regularizer- Parameters:
name- the name for this regularizer, if null the class name will be used.l1- L1 regularization factor, if null it is set to 0.l2- L2 regularization factor, if null it is set to 0.- Throws:
IllegalArgumentException- if the l1 or l2 regularization factor isFloat.isNaN(float)ofFloat.isInfinite(float)
-
-
Method Details
-
call
-
getL1
public float getL1()Gets the L1 regularization factor- Returns:
- the L1 regularization factor
-
getL2
public float getL2()Gets the L2 regularization factor- Returns:
- the L2 regularization factor
-