Options
All
  • Public
  • Public/Protected
  • All
Menu

L2 weight regularization for a particular model.

example
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();
//...

Hierarchy

  • L2Regularization

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

gamma

gamma: number

model

model: Module

parameters

parameters: Variable<any>[]

Methods

getLoss

Generated using TypeDoc