I have a batch of graphs created using dgl.batch
. After running them through my model, I need to carry out a matrix multiplication operation for each graph within the batch. More precisely, I want to compute the product of a matrix with dimensions (number of nodes x dimensions) and another matrix with dimensions (dimensions x number of nodes) for every individual graph in the batch. I’ve considered using readout functions, but I haven’t found a suitable solution yet. Your guidance would be greatly appreciated. Thank you!
Hi @NilBiescas, DGL does not provide this irregular matrix multiplication. But I think there are two possible solutions two handle your issue. (1) Apply dgl.unbatch to split the graph into smaller ones and conduct matmul independently. (2) Apply padding so that all small graphs has the same number of nodes. Then you can use pytorch dense matmul by regarding the batch dimension as a leading dimension.
1 Like
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.