-
Hello everyone. I am trying to make a transformation dataset class that will be used in “pre_transform” of QM9 dataset, and I have came up with one issue when dealing with dictionaries. When having nodes of two different node types we can use the “inc” method as described in “Advanced Mini-Batching” post. However, is there a way to deal with dictionaries in a similar manner? So if I have a dictionary that matches an id with an edge {0:[0,1], 1:[2,3]...}, is it possible to make it work for batches later somehow? The problem that arises is that the values in the dictionary won’t get incremented when constructing a batch, thus leading to confusions. Is there a way to overcome this issue when constructing custom dataset transformation class? Thank you very much for your time in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 20 replies
-
Yes, that is possible. You can see that import torch
from torch_geometric.data import Batch, Data
class MyData(Data):
def __inc__(self, key, value, *args, **kwargs):
print(key, value)
return 0
data = MyData(x_dict={'1': torch.tensor([0]), '2': torch.tensor([1])})
batch = Batch.from_data_list([data, data])
print(batch) |
Beta Was this translation helpful? Give feedback.
Added this via #7643