Using a list of indicies instead of single index in get(self, idx) in Dataset #3256
-
Hi! I have sqlite database that contains data that I'd like to query in the Dataset class. I have a list of sqlite indicies Conceptually, the
However, this means that when the dataset is used in the ordinary way:
I have gone through both PyG and torch documentations but I just can't seem to figure this out. Any ideas are very welcome! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This sounds to me like you do not really need the from torch_geometric.data import Data, Batch
from torch.utils.data import DataLoader
def collate_fn(indices: List[int]):
# Query the database once
# Creating a list of data objects from the query
data_list = [Data(x=...), ...]
return Batch.from_data_list(data_list) # Create the batch
loader = DataLoader(range(num_graphs), batch_size=1024, collate_fn=collate_fn) |
Beta Was this translation helpful? Give feedback.
-
Thank you very much! |
Beta Was this translation helpful? Give feedback.
This sounds to me like you do not really need the
Dataset
class. Instead, you can do something like the following: