Skip to content
Discussion options

You must be logged in to vote

This sounds to me like you do not really need the Dataset class. Instead, you can do something like the following:

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)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by RasmusOrsoe
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants