fix division by zero

This commit is contained in:
Damian Stewart 2023-02-19 10:25:38 +01:00
parent 60702ee040
commit 7956e24b61
1 changed files with 1 additions and 1 deletions

View File

@ -23,7 +23,7 @@ from utils.isolate_rng import isolate_rng
def get_random_split(items: list[ImageTrainItem], split_proportion: float, batch_size: int) \ def get_random_split(items: list[ImageTrainItem], split_proportion: float, batch_size: int) \
-> tuple[list[ImageTrainItem], list[ImageTrainItem]]: -> tuple[list[ImageTrainItem], list[ImageTrainItem]]:
split_item_count = math.ceil(split_proportion * len(items) // batch_size) * batch_size split_item_count = math.ceil(split_proportion * len(items) / batch_size) * batch_size
# sort first, then shuffle, to ensure determinate outcome for the current random state # sort first, then shuffle, to ensure determinate outcome for the current random state
items_copy = list(sorted(items, key=lambda i: i.pathname)) items_copy = list(sorted(items, key=lambda i: i.pathname))
random.shuffle(items_copy) random.shuffle(items_copy)