Pytorch_geometric: Batch.to_data_list() for bipartite graph

Created on 27 Jun 2020  ·  3Comments  ·  Source: rusty1s/pytorch_geometric

❓ Questions & Help


Hello, Sorry to have another question.

I ran the Bipartite example (shown here: https://pytorch-geometric.readthedocs.io/en/latest/notes/batching.html?highlight=bipartite#bipartite-graphs).

class BipartiteData(Data):
    def __init__(self, edge_attr=None, edge_index=None, x_s=None, x_t=None, x=None, pos=None, **kwargs):
        super(BipartiteData, self).__init__(x=x, edge_attr=edge_attr, pos=pos, **kwargs)
        self.edge_index = edge_index
        self.x_s = x_s
        self.x_t = x_t

    def __inc__(self, key, value):
        if key == 'edge_index':
            return torch.tensor([[self.x_s.size(0)], [self.x_t.size(0)]])
        else:
            return super(BipartiteData, self).__inc__(key, value)

In my code, I am using graph.to_data_list() function to get the list of graphs, but I met a problem when the to_data_list() function in batch.py https://github.com/rusty1s/pytorch_geometric/blob/0229b609cd2880d9d5ba439fc45bacc4f3205c6e/torch_geometric/data/batch.py#L119 are going to call __inc__ function, then it raised an error AttributeError: 'NoneType' object has no attribute 'size'.

How can I do for this situation?

Best regards!

bug

All 3 comments

I will look into it :)

This is fixed in master :) Thanks for letting me know.

Thanks for your update!!

Was this page helpful?
0 / 5 - 0 ratings