Skip to content

Commit

Permalink
Fix for relative data augmentation and early stopping frequency >= 1
Browse files Browse the repository at this point in the history
  • Loading branch information
ChWick committed Feb 8, 2019
1 parent 9528da7 commit 8a2857b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion calamari_ocr/ocr/datasets/input_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def epoch_size(self):
if self.data_augmentation_amount >= 1:
return int(len(self) * self.data_augmentation_amount)

return 1 / (1 - self.data_augmentation_amount)
return int(1 / (1 - self.data_augmentation_amount) * len(self))

def preload(self, processes=1, progress_bar=False):
print("Preloading dataset type {} with size {}".format(self.dataset.mode, len(self)))
Expand Down
1 change: 1 addition & 0 deletions calamari_ocr/ocr/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def _run_train(self, train_net, test_net, codec, train_start_time, progress_bar)
early_stopping_frequency = int(early_stopping_frequency * iters_per_epoch) # relative to epochs
else:
early_stopping_frequency = int(early_stopping_frequency)
early_stopping_frequency = max(1, early_stopping_frequency)

if checkpoint_frequency < 0:
checkpoint_frequency = early_stopping_frequency
Expand Down

0 comments on commit 8a2857b

Please sign in to comment.