Download annotations/annotation_42/HTML/transfer_learning/chem/dataloader.py from mcy98/RECODE-H: direct link, hf CLI and curl.
- Browser
- Download file 2.57 kB
-
https://huggingface.co/datasets/mcy98/RECODE-H/resolve/main/annotations/annotation_42/HTML/transfer_learning/chem/dataloader.py
- Command line
-
hf download hf://datasets/mcy98/RECODE-H/annotations/annotation_42/HTML/transfer_learning/chem/dataloader.py
-
curl -L -o dataloader.py https://huggingface.co/datasets/mcy98/RECODE-H/resolve/main/annotations/annotation_42/HTML/transfer_learning/chem/dataloader.py
2.57 kB
| import torch.utils.data | |
| from torch.utils.data.dataloader import default_collate | |
| from batch import BatchSubstructContext, BatchMasking, BatchAE | |
| class DataLoaderSubstructContext(torch.utils.data.DataLoader): | |
| r"""Data loader which merges data objects from a | |
| :class:`torch_geometric.data.dataset` to a mini-batch. | |
| Args: | |
| dataset (Dataset): The dataset from which to load the data. | |
| batch_size (int, optional): How may samples per batch to load. | |
| (default: :obj:`1`) | |
| shuffle (bool, optional): If set to :obj:`True`, the data will be | |
| reshuffled at every epoch (default: :obj:`True`) | |
| """ | |
| def __init__(self, dataset, batch_size=1, shuffle=True, **kwargs): | |
| super(DataLoaderSubstructContext, self).__init__( | |
| dataset, | |
| batch_size, | |
| shuffle, | |
| collate_fn=lambda data_list: BatchSubstructContext.from_data_list(data_list), | |
| **kwargs) | |
| class DataLoaderMasking(torch.utils.data.DataLoader): | |
| r"""Data loader which merges data objects from a | |
| :class:`torch_geometric.data.dataset` to a mini-batch. | |
| Args: | |
| dataset (Dataset): The dataset from which to load the data. | |
| batch_size (int, optional): How may samples per batch to load. | |
| (default: :obj:`1`) | |
| shuffle (bool, optional): If set to :obj:`True`, the data will be | |
| reshuffled at every epoch (default: :obj:`True`) | |
| """ | |
| def __init__(self, dataset, batch_size=1, shuffle=True, **kwargs): | |
| super(DataLoaderMasking, self).__init__( | |
| dataset, | |
| batch_size, | |
| shuffle, | |
| collate_fn=lambda data_list: BatchMasking.from_data_list(data_list), | |
| **kwargs) | |
| class DataLoaderAE(torch.utils.data.DataLoader): | |
| r"""Data loader which merges data objects from a | |
| :class:`torch_geometric.data.dataset` to a mini-batch. | |
| Args: | |
| dataset (Dataset): The dataset from which to load the data. | |
| batch_size (int, optional): How may samples per batch to load. | |
| (default: :obj:`1`) | |
| shuffle (bool, optional): If set to :obj:`True`, the data will be | |
| reshuffled at every epoch (default: :obj:`True`) | |
| """ | |
| def __init__(self, dataset, batch_size=1, shuffle=True, **kwargs): | |
| super(DataLoaderAE, self).__init__( | |
| dataset, | |
| batch_size, | |
| shuffle, | |
| collate_fn=lambda data_list: BatchAE.from_data_list(data_list), | |
| **kwargs) | |