Spaces:
Running
Running
File size: 885 Bytes
9d61c9b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
from typing import Any
from torch.utils.data import Dataset
class PreprocessedDataset(Dataset):
r"""A PyTorch Dataset for holding preprocessed data.
Attributes
data (list): The preprocessed data.
"""
def __init__(self, data: Any):
r"""Initialize the PreprocessedDataset.
Args:
data (list): The preprocessed data.
"""
self.data = data
def __getitem__(self, index: int):
r"""Get the data at the given index.
Args:
index (int): The index of the data to get.
Returns:
The data at the given index.
"""
return self.data[index]
def __len__(self):
r"""Get the number of data in the dataset.
Returns
The number of data in the dataset.
"""
return len(self.data)
|