Class WeightDecay

    • Field Detail

      • applyLR

        protected final boolean applyLR
    • Constructor Detail

      • WeightDecay

        public WeightDecay​(double coeff,
                           boolean applyLR)
        Parameters:
        coeff - Weight decay regularization coefficient
        applyLR - If true, multiply the regularization coefficient by the current learning rate. If false, do not multiply by LR.
      • WeightDecay

        public WeightDecay​(@NonNull
                           @NonNull ISchedule coeff,
                           boolean applyLR)
        Parameters:
        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.
    • Method Detail

      • apply

        public void apply​(INDArray param,
                          INDArray gradView,
                          double lr,
                          int iteration,
                          int epoch)
        Description copied from interface: Regularization
        Apply the regularization by modifying the gradient array in-place
        Specified by:
        apply in interface Regularization
        Parameters:
        param - Input array (usually parameters)
        gradView - Gradient view array (should be modified/updated). Same shape and type as the input array.
        lr - Current learning rate
        iteration - Current network training iteration
        epoch - Current network training epoch
      • score

        public double score​(INDArray param,
                            int iteration,
                            int epoch)
        Description copied from interface: Regularization
        Calculate the loss function score component for the regularization.
        For example, in L2 regularization, this would return L = 0.5 * sum_i param[i]^2
        For regularization types that don't have a score component, this method can return 0. However, note that this may make the regularization type not gradient checkable.
        Specified by:
        score in interface Regularization
        Parameters:
        param - Input array (usually parameters)
        iteration - Current network training iteration
        epoch - Current network training epoch
        Returns:
        Loss function score component based on the input/parameters array