public class WeightDecay extends Object implements Regularization
L = loss + coeff * 0.5 * sum_i w[i]^2L2Regularization
For all cases, w -= updateapplyLR == true, we have:
update = updater(gradient) + lr * coeff * wlr is the learning rate for the current iteration/epoch (accounting for LR schedules if present).applyLR == false, we have:update = updater(gradient) + coeff * wRegularization.ApplyStep| Modifier and Type | Field and Description |
|---|---|
protected boolean |
applyLR |
protected ISchedule |
coeff |
| Constructor and Description |
|---|
WeightDecay(double coeff,
boolean applyLR) |
WeightDecay(ISchedule coeff,
boolean applyLR) |
| Modifier and Type | Method and Description |
|---|---|
void |
apply(INDArray param,
INDArray gradView,
double lr,
int iteration,
int epoch)
Apply the regularization by modifying the gradient array in-place
|
Regularization.ApplyStep |
applyStep() |
Regularization |
clone() |
double |
score(INDArray param,
int iteration,
int epoch)
Calculate the loss function score component for the regularization.
For example, in L2 regularization, this would return L = 0.5 * sum_i param[i]^2For regularization types that don't have a score component, this method can return 0. |
protected final ISchedule coeff
protected final boolean applyLR
public WeightDecay(double coeff,
boolean applyLR)
coeff - Weight decay regularization coefficientapplyLR - If true, multiply the regularization coefficient by the current learning rate. If false, do not multiply by LR.public WeightDecay(@NonNull
ISchedule coeff,
boolean applyLR)
coeff - Weight decay regularization coefficient (schedule)applyLR - If true, multiply the regularization coefficient by the current learning rate. If false, do not multiply by LR.public Regularization.ApplyStep applyStep()
applyStep in interface RegularizationRegularization.ApplySteppublic void apply(INDArray param, INDArray gradView, double lr, int iteration, int epoch)
Regularizationapply in interface Regularizationparam - Input array (usually parameters)gradView - Gradient view array (should be modified/updated). Same shape and type as the input array.lr - Current learning rateiteration - Current network training iterationepoch - Current network training epochpublic double score(INDArray param, int iteration, int epoch)
RegularizationL = 0.5 * sum_i param[i]^2score in interface Regularizationparam - Input array (usually parameters)iteration - Current network training iterationepoch - Current network training epochpublic Regularization clone()
clone in interface Regularizationclone in class ObjectCopyright © 2019. All rights reserved.