Vowpal Wabbit
Public Member Functions | List of all members
hingeloss Class Reference
Inheritance diagram for hingeloss:
loss_function

Public Member Functions

std::string getType ()
 
float getLoss (shared_data *, float prediction, float label)
 
float getUpdate (float prediction, float label, float update_scale, float pred_per_update)
 
float getUnsafeUpdate (float prediction, float label, float update_scale)
 
float getRevertingWeight (shared_data *, float prediction, float eta_t)
 
float getSquareGrad (float prediction, float label)
 
float first_derivative (shared_data *, float prediction, float label)
 
float second_derivative (shared_data *, float, float)
 
- Public Member Functions inherited from loss_function
virtual ~loss_function ()
 

Detailed Description

Definition at line 116 of file loss_functions.cc.

Member Function Documentation

◆ first_derivative()

float hingeloss::first_derivative ( shared_data ,
float  prediction,
float  label 
)
inlinevirtual

Implements loss_function.

Definition at line 152 of file loss_functions.cc.

152 { return (label * prediction >= 1) ? 0 : -label; }

◆ getLoss()

float hingeloss::getLoss ( shared_data ,
float  prediction,
float  label 
)
inlinevirtual

Implements loss_function.

Definition at line 121 of file loss_functions.cc.

References f.

122  {
123  if (label != -1.f && label != 1.f)
124  std::cout << "You are using label " << label << " not -1 or 1 as loss function expects!" << std::endl;
125  float e = 1 - label * prediction;
126  return (e > 0) ? e : 0;
127  }
float f
Definition: cache.cc:40

◆ getRevertingWeight()

float hingeloss::getRevertingWeight ( shared_data ,
float  prediction,
float  eta_t 
)
inlinevirtual

Implements loss_function.

Definition at line 144 of file loss_functions.cc.

144 { return fabs(prediction) / eta_t; }

◆ getSquareGrad()

float hingeloss::getSquareGrad ( float  prediction,
float  label 
)
inlinevirtual

Implements loss_function.

Definition at line 146 of file loss_functions.cc.

References squaredloss::first_derivative().

147  {
148  float d = first_derivative(nullptr, prediction, label);
149  return d * d;
150  }
float first_derivative(shared_data *, float prediction, float label)

◆ getType()

std::string hingeloss::getType ( )
inlinevirtual

Implements loss_function.

Definition at line 119 of file loss_functions.cc.

119 { return "hinge"; }

◆ getUnsafeUpdate()

float hingeloss::getUnsafeUpdate ( float  prediction,
float  label,
float  update_scale 
)
inlinevirtual

Implements loss_function.

Definition at line 137 of file loss_functions.cc.

138  {
139  if (label * prediction >= 1)
140  return 0;
141  return label * update_scale;
142  }

◆ getUpdate()

float hingeloss::getUpdate ( float  prediction,
float  label,
float  update_scale,
float  pred_per_update 
)
inlinevirtual

Implements loss_function.

Definition at line 129 of file loss_functions.cc.

130  {
131  if (label * prediction >= 1)
132  return 0;
133  float err = 1 - label * prediction;
134  return label * (update_scale * pred_per_update < err ? update_scale : err / pred_per_update);
135  }

◆ second_derivative()

float hingeloss::second_derivative ( shared_data ,
float  ,
float   
)
inlinevirtual

Implements loss_function.

Definition at line 154 of file loss_functions.cc.

154 { return 0.; }

The documentation for this class was generated from the following file: