rusty1s / deep-graph-matching-consensus

Implementation of "Deep Graph Matching Consensus" in PyTorch
https://openreview.net/forum?id=HyeJf1HKvS
MIT License
256 stars 47 forks source link

Doubt about Multiple Graphs #2

Closed zongshenmu closed 4 years ago

zongshenmu commented 4 years ago

When I run dgmc on batch multi-graphs, the S_L get the wrong size and values. But I look the test_dgmc and believe that the model support it. So I want to know that wether it can run the batch data on multi-graph

rusty1s commented 4 years ago

You mean a graph with multiple (typed) edges? Sure, that should be no problem. Since DGMC only considers node correspondences in S_L, I am wondering what you mean with "it gets the wrong size". Maybe you can show me a minimal example to reproduce?

zongshenmu commented 4 years ago

You paper mentioned that Vs<=Vt, so I try the case Gs have 2 nodes and Gt have 5 nodes and it works. But I try the case there are different graphs of Vs<=Vt, the result of S_L make me confused. For example, v1s = torch.randn(2, 32) e1s = torch.tensor([[0, 1], [1, 1]]) data1s = Data(x=v1s, edge_index=e1s) v1t=torch.randn(4, 32) e1t=torch.tensor([[0, 1, 1, 2, 2, 3], [1, 0, 2, 1, 3, 2]]) data1t = Data(x=v1t, edge_index=e1t)

v2s = torch.randn(3, 32) e2s = torch.tensor([[0, 1,2], [1, 2,0]]) data2s = Data(x=v2s, edge_index=e2s) v2t = torch.randn(5, 32) e2t = torch.tensor([[0, 1, 1, 3, 2, 3], [1, 0, 2, 4, 3, 2]]) data2t = Data(x=v2t, edge_index=e2t)

v3s = torch.randn(2, 32) e3s = torch.tensor([[1,0], [0,1]]) data3s = Data(x=v3s, edge_index=e3s) v3t = torch.randn(3, 32) e3t = torch.tensor([[0, 1, 1, 2], [1, 2, 1, 2]]) data3t = Data(x=v3t, edge_index=e3t)

batchs = Batch.from_data_list([data1s, data2s,data3s]) batcht = Batch.from_data_list([data1t, data2t,data3t])

psi_1 = GIN(32, 16, num_layers=2) psi_2 = GIN(8, 8, num_layers=2)

model = DGMC(psi_1, psi_2, numsteps=2,k=10) , S_L = model(batchs.x,batchs.edge_index,None,batchs.batch,batcht.x,batcht.edge_index,None,batcht.batch) print(S_L.size())

cmd: torch.Size([7, 5])

rusty1s commented 4 years ago

That looks correct to me. Note that S_L isn't handled as a [batch_size, max_num_nodes_s, max_num_nodes_t] matrix, but instead unifies batch_size and num_nodes_s in the first dimension to save memory. So we have 2+3+2=7 in the first dimension and max(4, 5, 3)=5 in the second dimension.

zongshenmu commented 4 years ago

I get it. So dealing with the batch graphs with vs<=vt, the code is practical when the num nodes of target graphs are same. Thanks