Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion climanet/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ def predict_monthly_var(
model.to(device)
model.eval()

# Length of the dataset should >=1
if len(dataset) < 1:
raise ValueError("The dataset is empty. Please provide a non-empty dataset.")

use_cuda = device == "cuda"
dataloader = DataLoader(
dataset,
Expand All @@ -116,7 +120,7 @@ def predict_monthly_var(

with torch.inference_mode():
idx = 0
average_loss = 0.0
average_loss = torch.tensor(0.0, device=device)
for i, batch in enumerate(dataloader):
# Move batch to the appropriate device
batch = {k: v.to(device, non_blocking=use_cuda) for k, v in batch.items()}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading