shark::GeneralizationLoss< PointType > Class Template Reference

The generalization loss calculates the relative increase of the validation error compared to the minimum training error. More...

#include <shark/Algorithms/StoppingCriteria/GeneralizationLoss.h>

+ Inheritance diagram for shark::GeneralizationLoss< PointType >:

Public Types

typedef ValidatedSingleObjectiveResultSet< PointType > ResultSet
 
- Public Types inherited from shark::AbstractStoppingCriterion< ValidatedSingleObjectiveResultSet< PointType > >
typedef ValidatedSingleObjectiveResultSet< PointType > ResultSet
 

Public Member Functions

 GeneralizationLoss (double maxLoss)
 
bool stop (const ResultSet &set)
 
void reset ()
 resets the internal state More...
 
double value () const
 returns the current generalization loss More...
 

Protected Attributes

double m_minTraining
 minimum training error More...
 
double m_minValidation
 minimum validation error More...
 
double m_maxLoss
 maximum loss allowed More...
 
double m_gl
 current generalization loss More...
 

Detailed Description

template<class PointType = RealVector>
class shark::GeneralizationLoss< PointType >

The generalization loss calculates the relative increase of the validation error compared to the minimum training error.

The generalization loss at iteration t is calculated as \( GL(t) 100 \left( \frac {E_v(t)} {\min_{t'} E_l(t')} -1 \right) \) where \( E_v \) is the validation error and \( E_l \) the training error. This is a good indicator for overfitting, since it measures directly the gap between the two values. This method stops when the generalization error is bigger than some predefined value. The disadvantage is, that when the training error is still changing much a big generalization loss might be repaired later on. So this method might stop to soon.

Terminology for this and other stopping criteria is taken from (and also see):

Lutz Prechelt. Early Stopping - but when? In Genevieve B. Orr and Klaus-Robert Müller: Neural Networks: Tricks of the Trade, volume 1524 of LNCS, Springer, 1997.

Definition at line 61 of file GeneralizationLoss.h.

Member Typedef Documentation

◆ ResultSet

template<class PointType = RealVector>
typedef ValidatedSingleObjectiveResultSet<PointType> shark::GeneralizationLoss< PointType >::ResultSet

Definition at line 63 of file GeneralizationLoss.h.

Constructor & Destructor Documentation

◆ GeneralizationLoss()

template<class PointType = RealVector>
shark::GeneralizationLoss< PointType >::GeneralizationLoss ( double  maxLoss)
inline

constructs a generaliazationLoss which stops, when the GL > maxLoss

Parameters
maxLossmaximum loss allowed before stopping

Definition at line 66 of file GeneralizationLoss.h.

References shark::GeneralizationLoss< PointType >::m_maxLoss, and shark::GeneralizationLoss< PointType >::reset().

Member Function Documentation

◆ reset()

template<class PointType = RealVector>
void shark::GeneralizationLoss< PointType >::reset ( )
inlinevirtual

◆ stop()

template<class PointType = RealVector>
bool shark::GeneralizationLoss< PointType >::stop ( const ResultSet set)
inlinevirtual

returns true if the training should stop. The generalization loss orders the optimizer to stop as soon as the validation error grows larger than a certain factor of the minimum validation error encountered so far.

Implements shark::AbstractStoppingCriterion< ValidatedSingleObjectiveResultSet< PointType > >.

Definition at line 74 of file GeneralizationLoss.h.

References shark::GeneralizationLoss< PointType >::m_minTraining.

◆ value()

template<class PointType = RealVector>
double shark::GeneralizationLoss< PointType >::value ( ) const
inline

returns the current generalization loss

Definition at line 85 of file GeneralizationLoss.h.

References shark::GeneralizationLoss< PointType >::m_gl.

Member Data Documentation

◆ m_gl

template<class PointType = RealVector>
double shark::GeneralizationLoss< PointType >::m_gl
protected

current generalization loss

Definition at line 97 of file GeneralizationLoss.h.

Referenced by shark::GeneralizationLoss< PointType >::value().

◆ m_maxLoss

template<class PointType = RealVector>
double shark::GeneralizationLoss< PointType >::m_maxLoss
protected

maximum loss allowed

Definition at line 95 of file GeneralizationLoss.h.

Referenced by shark::GeneralizationLoss< PointType >::GeneralizationLoss().

◆ m_minTraining

template<class PointType = RealVector>
double shark::GeneralizationLoss< PointType >::m_minTraining
protected

◆ m_minValidation

template<class PointType = RealVector>
double shark::GeneralizationLoss< PointType >::m_minValidation
protected

minimum validation error

Definition at line 92 of file GeneralizationLoss.h.


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