Download datautils.py from minhtuyenvp02/docker-local: direct link, hf CLI and curl.
- Browser
- Download file 331 Bytes
-
https://huggingface.co/datasets/minhtuyenvp02/docker-local/resolve/main/datautils.py
- Command line
-
hf download hf://datasets/minhtuyenvp02/docker-local/datautils.py
-
curl -L -o datautils.py https://huggingface.co/datasets/minhtuyenvp02/docker-local/resolve/main/datautils.py
331 Bytes
| import torch | |
| from torch.utils.data import Dataset | |
| class MyTrainDataset(Dataset): | |
| def __init__(self, size): | |
| self.size = size | |
| self.data = [(torch.rand(20), torch.rand(1)) for _ in range(size)] | |
| def __len__(self): | |
| return self.size | |
| def __getitem__(self, index): | |
| return self.data[index] |