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.

How can I input two different types of graghs into the network at the same time?

See original GitHub issue

❓ Questions & Help

Hi~ I now have a network input that is two types of graphs,GraphA and GraphB. These two Graphs correspond to the same label. So, How do I input these two types of graphs at the same time? I have two ideas:

  1. Put both Graphs in the same Dataloader, But I don’t know how to implement it, it may destroy the graph’s structure inside.
  2. Use two Dataloaders for GraphA and GraphB,and do this:
for batch1, batch2 in zip(data_loaderA, data_loaderB):
    batch1, batch2

But, if I set the parameter of dataloader, shuffle=True. These two dataloaders will not generate the same random number, which will cause batch1, batch2 to lose the corresponding relationship, without the same label.

I really need your advice, thank you!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
rusty1scommented, Nov 5, 2019

I believe the easiest way is to define a new PairDataset:

class PairDataset(torch.utils.data.Dataset):
    def __init__(self, datasetA, datasetB):
        ...

    def __getitem__(self, idx):
        return self.datasetA[idx], self.datasetB[idx]

and use it in a PyTorch DataLoader as follows:

from torch_geometric.data import Batch

def collate(self, data_list):
    batchA = Batch.from_data_list([data[0] for data in data_list])
    batchB = Batch.from_data_list([data[1] for data in data_list])
    return batchA, batchB

torch.utils.DataLoader(pair_dataset, batch_size=..., shuffle=True, collate_fn=collate)
0reactions
YunYunYcommented, Aug 5, 2021

Thank you so much. The issue has been solved in discussion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Need to combine two chart types? Create a combo ... - Microsoft
Combining different chart types and adding a secondary axis​​ 2. Go to the Insert tab and click Recommended Charts. 3. Click the All...
Read more >
Plot Multiple Data Sets on the Same Chart in Excel
In this article, we are going to see how to make combination charts from a set of two different charts in Excel using...
Read more >
Network Graphs - DIGI
Nodes can be of the same or different category within a network graph. With that said, a network can show relationships between people,...
Read more >
How To Show Two Sets of Data on One Graph in Excel - Indeed
From the options in the "Recommended Charts" section, select "All Charts" and when the new dialog box appears, choose "Combo" as the chart...
Read more >
Chapter 3: Using Graphs to Represent Social Relations
Social network analysts use two kinds of tools from mathematics to represent information about patterns of ties among social actors: graphs and matrices....
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