Hello and sorry, that i have to ask again concerning dataset creation.
My current problem is, that i have my data object in the following form:
x.shape = [4289, 438]
edge_index.shape = [4390, 2]
edge_attr.shape = [4390]
x.shape = [3193, 438]
edge_index.shape = [3804, 2]
edge_attr.shape = [3804]
Now when the dataset comes to data, slices = self.collate(data_list)
I get a RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 4390 and 3804 in dimension 0 at C:\w\1\s\tmp_conda_3.7_055457\conda\conda-bld\pytorch_1565416617654\work\ate
n\src\TH/generic/THTensor.cpp:689
But as far as it only tells me, that my tensors should match in dimension 1, which they do. They are both at 438. So why do i still get an error? (Sorry again if it's a basic question, but i just can't seam to figure it out)
Could this be, because i have more edges, then nods? This results, because some of my edges do have multiple attributes.
edge_index.shape must be [2, *]
in your case [2, 4390] and [2, 3804]
Thank you very much for the quick help
I have not finished yet :) Just have been looking for documentation.
You can transform your edge_index to correct format by calling edge_index.t().contiguous()
Example:
import torch
from torch_geometric.data import Data
edge_index = torch.tensor([[0, 1],
[1, 0],
[1, 2],
[2, 1]], dtype=torch.long)
x = torch.tensor([[-1], [0], [1]], dtype=torch.float)
data = Data(x=x, edge_index=edge_index.t().contiguous())
>>> Data(edge_index=[2, 4], x=[3, 1])
from here: https://pytorch-geometric.readthedocs.io/en/latest/notes/introduction.html?highlight=contiguous#data-handling-of-graphs
That is it. :)
Thanks. I never came back to the introduction by example and totally missed that.
Sorry for having to ask, but thank you for your patience in helping me.
Most helpful comment
Thanks. I never came back to the introduction by example and totally missed that.
Sorry for having to ask, but thank you for your patience in helping me.