Replies: 2 comments 2 replies
-
I think you can do the same for PyG. Use a |
Beta Was this translation helpful? Give feedback.
-
Sorry for updating this thread. I have a question about the # Example graph data generation
bagraph = barabasi_albert_graph(num_nodes=100, num_edges=80)
example_feature = torch.rand(100, 256)
example_graph = Data(edge_index=bagraph, x=example_feature)
example_graph
# Data(x=[100, 256], edge_index=[2, 1394]) <- why it returns 1394 edges while I set num_edges=80?
# train/val/test separation
batch_size = 32
transform = RandomLinkSplit(num_val=0.1, num_test=0.2, is_undirected=True, split_labels=True)
train_data, val_data, test_data = transform(example_graph)
train_data
# Data(x=[100, 256], edge_index=[2, 978], pos_edge_label=[489], pos_edge_label_index=[2, 489], neg_edge_label=[489], neg_edge_label_index=[2, 489])
train_loader = DataLoader(train_data, shuffle=True, batch_size=batch_size)
val_loader = DataLoader(val_data, shuffle=True, batch_size=batch_size)
test_loader = DataLoader(test_data, shuffle=False, batch_size=batch_size) the data loaders couldn't get mini-batches with KeyError. for batch in loader:
# Access the batch data
batch_x = batch.x
batch_edge_index = batch.edge_index
# KeyError: 2 Full error message
It seems like that loader can't separate the graph and I guess it needs |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In the perspective of contrastive learning applications, I would like my
DataLoader
to return a tuple ofBatch
objects according to some positives/negatives mining technique. By using standardtorch.utils.DataLoader
this can be accomplished by a customcollate_fn
like:Is there anything I can do to retrieve a similar thing by using PyG?
Beta Was this translation helpful? Give feedback.
All reactions