in #U57fa#U7840#U6559#U7a0b/A2-#U795e#U7ecf#U7f51#U7edc#U57fa#U672c#U539f#U7406/#U7b2c8#U6b65 - #U5377#U79ef#U795e#U7ecf#U7f51#U7edc/src/ch17-CNNBasic/MiniFramework/TrainingHistory_3_0.py [0:0]
def Add(self, epoch, total_iteration, loss_train, accuracy_train, loss_vld, accuracy_vld, stopper):
self.iteration_seq.append(total_iteration)
self.epoch_seq.append(epoch)
self.loss_train.append(loss_train)
self.accuracy_train.append(accuracy_train)
if loss_vld is not None:
self.loss_val.append(loss_vld)
if accuracy_vld is not None:
self.accuracy_val.append(accuracy_vld)
if stopper is not None:
if stopper.stop_condition == StopCondition.StopDiff:
if len(self.loss_val) > 1:
if abs(self.loss_val[-1] - self.loss_val[-2]) < stopper.stop_value:
self.counter = self.counter + 1
if self.counter > 3:
return True
else:
self.counter = 0
#end if
#end if
#end if
if self.early_stop:
if loss_vld < self.last_vld_loss:
self.patience_counter = 0
self.last_vld_loss = loss_vld
else:
self.patience_counter += 1
if self.patience_counter >= self.patience:
return True # need to stop
# end if
# end if
return False