MCPcopy Create free account
hub / github.com/chengsen/PyTorch_TextGCN / __call__

Method __call__

utils.py:176–193  ·  view source on GitHub ↗
(self, val_loss, model=None)

Source from the content-addressed store, hash-verified

174 self.model_path = "hdd_data/prepare_dataset/model/model.pt"
175
176 def __call__(self, val_loss, model=None):
177
178 score = -val_loss
179
180 if self.best_score is None:
181 self.best_score = score
182 # self.save_checkpoint(val_loss, model)
183 elif score < self.best_score + self.delta:
184 self.counter += 1
185 if self.verbose:
186 print(f'EarlyStopping counter: {self.counter} out of {self.patience}')
187 if self.counter >= self.patience:
188 self.early_stop = True
189 return True
190 else:
191 self.best_score = score
192 # self.save_checkpoint(val_loss, model)
193 self.counter = 0
194
195 def save_checkpoint(self, val_loss, model):
196 '''Saves model when validation loss decrease.'''

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected