question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Integrating source_to_target and target_to_source flow in bipartite graph.

See original GitHub issue

❓ Questions & Help

Hello! Thank you for building such a well-documented and well-maintained library. I’m new to Graph Neural Networks, and I am learning to build a bipartite graph network, for the following nodes: github_issue

I have gone through issues page to understand how to integrate source_to_target and target_to_source flows for some nodes. So currently, I made 2 BipartiteData objects, where edge_index is defined differently:

x_s = ... # size [7, 300]
x_t = ... # size [7, 11]
edge_index_1 = torch.tensor([[0, 1, 4, 4, 4, 4, 6], [3, 1, 0, 2, 5, 6, 4]], dtype=torch.long) #for source_to_target
edge_index_2 = torch.tensor([0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6]], dtype=torch.long) #for target_to_source
graph_data_1 = BipartiteData(x_s=x_s, edge_index=edge_index_1, x_t=x_t)
graph_data_2 = BipartiteData(x_s=x_s, edge_index=edge_index_2, x_t=x_t)

Then, graph_data_1 and graph_data_2 are passed through separate GCN layers; where one overrides MessagePassing with flow = 'source_to_target' and the other overrides MessagePassing with flow = 'target_to_source'.

Is this a good approach to this problem? Also, how do I further join the outputs of the 2 GCN layers and get an overall node representation?

Your clarification will be appreciated 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

6reactions
rusty1scommented, May 19, 2020

Yeah, the batch object is not present because PyG cannot identify how to create it. You can pass the follow_batch argument to the DataLoader to signal PyG which batches it should track:

def __inc__(self, key, value):
      # Returns the incremental count to cumulatively increase the value
      # of the next attribute of :obj:`key` when creating batches.
      if (key == 'edge_index_s2t':
          return torch.tensor([[self.x_s.size(0)], [self.x_t.size(0)]])
      elif (key == 'edge_index_t2s':
          return torch.tensor([[self.x_t.size(0)], [self.x_s.size(0)]])
      else:
          return super(BipartiteData, self).__inc__(key, value)


loader = DataLoader(dataset, batch_size=..., follow_batch=['x_s', 'x_t'])
3reactions
rusty1scommented, May 15, 2020

You can also define it as

class BipartiteData(Data):
    def __init__(self, edge_index_s2t, edge_idnex_t2s, x_s, x_t):
        super(BipartiteData, self).__init__()
        self.edge_index_s2t = edge_index_s2t
        self.edge_index_t2s = edge_index_t2s
        self.x_s = x_s
        self.x_t = x_t

    def __inc__(self, key, item):
        ...

There is no limitation in how many attributes you can store in data.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Integrating source_to_target and target_to_source flow in ...
Aim: I need to find the node representations of source nodes, from this bipartite graph. Question 1: Does the MessagePassing network only flow...
Read more >
CMSC 451: Maximum Bipartite Matching
We're given A and B so we don't have to find them. • S is a perfect matching if every vertex is matched....
Read more >
Network Flows: Bipartite Matching
We conclude our discussion of network flows with an application to bipartite matching. We need the following definitions: A graph G(V,E) is a...
Read more >
Max flow solves bipartite matching - YouTube
This project was created with Explain Everything™ Interactive Whiteboard for iPad.
Read more >
Integrated Optimization of Bipartite Matching and Its Stochastic ...
We propose a fast approximation algorithm via a min-cost flow algorithm that can output 3-approximation solutions for. ISPCB. 3. We conduct simulation ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found