I am using the edge loader to load a toy heterograph. Sometimes I see a Block
like this
Block(num_src_nodes={'image': 3, 'tag': 2},
num_dst_nodes={'image': 3, 'tag': 2},
num_edges={('image', 'hasTag', 'tag'): 0, ('image', 'similarTo', 'image'): 2, ('image', 'similarToReverse', 'image'): 3, ('tag', 'hasImage', 'image'): 1},
metagraph=[('image', 'tag', 'hasTag'), ('image', 'image', 'similarTo'), ('image', 'image', 'similarToReverse'), ('tag', 'image', 'hasImage')])
As you see, num_dst_nodes['tag'] = 2
, but there is no edge pointing to a tag according to num_edges
. I have attached the relevant code.
Relevant code
Graph -
graph_data = {
('image', 'similarTo', 'image'): (th.tensor([0, 1, 2]), th.tensor([1, 0, 0])),
('image', 'similarToReverse', 'image'): (th.tensor([1, 0, 0]), th.tensor([0, 1, 2])),
('image', 'hasTag', 'tag'): (th.tensor([0, 1, 2, 2]), th.tensor([0, 1, 0, 1])),
('tag', 'hasImage', 'image'): (th.tensor([0, 1, 0, 1]), th.tensor([0, 1, 2, 2]))
}
Dataloader -
train_seeds = {
'similarTo': th.arange(3),
'similarToReverse': th.arange(3),
'hasTag': th.arange(4),
'hasImage': th.arange(4)
}
sampler = dgl.dataloading.MultiLayerNeighborSampler(
[1, 1])
train_dataloader = dgl.dataloading.EdgeDataLoader(
g, train_seeds, sampler, exclude='reverse_types',
reverse_etypes={
'similarTo': 'similarToReverse',
'similarToReverse': 'similarTo',
'hasTag': 'hasImage',
'hasImage': 'hasTag'
}
Can you help me figuring out the error? I’m happy to provide a minimal script to demonstrate this if needed.
Thanks!