mirror of
https://github.com/rasbt/LLMs-from-scratch.git
synced 2026-04-10 12:33:42 +00:00
Return nan if val loader is empty (#124)
This commit is contained in:
committed by
GitHub
parent
b5878a80ff
commit
4557d5830e
@@ -255,7 +255,9 @@ def calc_loss_batch(input_batch, target_batch, model, device):
|
||||
|
||||
def calc_loss_loader(data_loader, model, device, num_batches=None):
|
||||
total_loss = 0.
|
||||
if num_batches is None:
|
||||
if len(data_loader) == 0:
|
||||
return float("nan")
|
||||
elif num_batches is None:
|
||||
num_batches = len(data_loader)
|
||||
else:
|
||||
num_batches = min(num_batches, len(data_loader))
|
||||
|
||||
Reference in New Issue
Block a user