Belle II Software light-2406-ragdoll
early_stopping Class Reference

Public Member Functions

def __init__ (self)
 
def check (self, cost)
 

Public Attributes

 counter
 counts how many times training is not getting better
 
 best_result
 saves best training result
 

Detailed Description

 Using class to stop training early if it's not getting better

Definition at line 20 of file relations.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)
 init class 

Definition at line 23 of file relations.py.

23 def __init__(self):
24 """ init class """
25
26 self.counter = 0
27
28 self.best_result = np.inf
29

Member Function Documentation

◆ check()

def check (   self,
  cost 
)
Check if validation result is better than the best validation result.
Decide if training should be continued.

Definition at line 30 of file relations.py.

30 def check(self, cost):
31 """
32 Check if validation result is better than the best validation result.
33 Decide if training should be continued.
34 """
35 if cost < self.best_result:
36 self.counter = 0
37 self.best_result = cost
38 else:
39 self.counter += 1
40 if self.counter >= 20:
41 return False
42 return True
43
44

Member Data Documentation

◆ best_result

best_result

saves best training result

Definition at line 28 of file relations.py.

◆ counter

counter

counts how many times training is not getting better

Definition at line 26 of file relations.py.


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