void CL2N2::ComputeReg(CModel& model, double& reg) { reg = 0; TheMatrix &w = model.GetW(); w.Norm2(reg); reg = 0.5*reg*reg; }
void CL2N2::ComputeRegAndGradient(CModel& model, double& reg, TheMatrix& grad) { reg = 0; TheMatrix &w = model.GetW(); w.Norm2(reg); reg = 0.5*reg*reg; grad.Assign(w); }
/** The subgradient is chosen as sgn(w) */ void CL1N1::ComputeRegAndGradient(CModel& model, double& reg, TheMatrix& grad) { reg = 0; TheMatrix &w = model.GetW(); w.Norm1(reg); grad.Zero(); for(int i=0; i<w.Length(); i++) { double val = 0; w.Get(i,val); grad.Set(i,SML::sgn(val)); } }
void CL1N1::ComputeReg(CModel& model, double& reg) { reg = 0; TheMatrix &w = model.GetW(); w.Norm1(reg); }