Skip to content

Commit

Permalink
Updated a bug, added batches_per_epoch method to the dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
jsschreck committed Dec 20, 2024
1 parent 81a88ed commit 3452571
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions credit/datasets/era5_multistep_batcher.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import time
import math
import queue
import multiprocessing
from threading import Thread
Expand Down Expand Up @@ -332,8 +333,12 @@ def set_epoch(self, epoch):
self.current_epoch = epoch
self.sampler.set_epoch(epoch)
self.batch_indices = list(self.sampler)
self.batch_call_count = 0
self.initialize_batch()

def batches_per_epoch(self):
return math.ceil((self.batch_indices) / self.batch_size)

def __getitem__(self, _):
"""
Fetches the current forecast step data for each item in the batch.
Expand Down Expand Up @@ -507,6 +512,7 @@ def set_epoch(self, epoch):
self.current_epoch = epoch
self.sampler.set_epoch(epoch)
self.batch_indices = list(self.sampler)
self.batch_call_count = 0
self.initialize_batch()

# Start prefetching thread
Expand Down

0 comments on commit 3452571

Please sign in to comment.