Example #1
0
File: l2n2.cpp Project: funkey/bmrm
void CL2N2::ComputeReg(CModel& model, double& reg)
{
   reg = 0;
   TheMatrix &w = model.GetW();
   w.Norm2(reg);
	reg = 0.5*reg*reg;
}
Example #2
0
File: l2n2.cpp Project: funkey/bmrm
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); 	
}
Example #3
0
File: l1n1.cpp Project: funkey/bmrm
/** 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));
   }
}
Example #4
0
File: l1n1.cpp Project: funkey/bmrm
void CL1N1::ComputeReg(CModel& model, double& reg)
{
   reg = 0;
   TheMatrix &w = model.GetW();
   w.Norm1(reg);
}