Spaces:
Sleeping
Sleeping
File size: 569 Bytes
67eaf9f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import torch
from torch.utils.data import DataLoader
class TestDataset(torch.utils.data.Dataset):
def __init__(self, encodings: list[dict[str, list]]):
self.encodings = encodings
def __getitem__(self, idx):
item = {key: torch.tensor(val) for key, val in self.encodings[idx].items()}
return item
def __len__(self):
return len(self.encodings)
def create_dataloader(dat: list[dict[str, list]], batch_size: int) -> DataLoader:
return DataLoader(TestDataset(dat), batch_size=batch_size, shuffle=False)
|