Skip to contents

Formula: L(w, lambda) = L(w) + 0.5 * lambda * w'w

Usage

L2pen(loss, w, lam)

Arguments

loss

Unregularized loss L(w).

w

Network weights.

lam

Penalty strength lambda; must be non-negative.

Value

List with penalized_loss, penalty, ep, lambda, p.

References

Montesinos Lopez, Montesinos Lopez and Crossa (2022), Multivariate Statistical Machine Learning Methods for Genomic Prediction, Springer, doi:10.1007/978-3-030-89010-0. Chapter 10, Sect. 10.7.3 p. 403: L(w, lambda) = L(w) + 0.5 * lambda * E_P, with E_P = w'w for the ridge (weight decay, L2) penalty. Read from the chapter PDF, not recalled.

Examples

L2pen(loss = 1.2, w = c(0.5, -1), lam = 0.1)$penalized_loss   # 1.2 + 0.05 * 1.25
#> [1] 1.2625