L2 weight regularization for a particular model.
const model = new Linear(32,1); const regularizer = new L2Regularization(model, 0.01); //... const prediction = (await model.forward([x]))[0]; let loss = prediction.subtract(y).reduceSumSquare(); loss = loss.add(regularizer.getLoss()); //... loss.backward(); //...
Generated using TypeDoc
L2 weight regularization for a particular model.