Skip to content

How to convert PyG heterograph to DeepSnap heterograph? #43

Description

@Jeriousman

I made a PyG heterograph as below.

cipdata
Out[145]: 
HeteroData(
  card={ x=[13752, 302] },
  user={ x=[10996, 304] },
  (user, solved, card)={
    edge_index=[2, 28992],
    edge_attr=[28992]
  },
  (card, rev_solved, user)={
    edge_index=[2, 28992],
    edge_attr=[28992]
  }
)

Then I tried to convert this cipdata PyG heterograph into DeepSnap's heterograph

from deepsnap.hetero_graph import HeteroGraph
graph = HeteroGraph(cipdata)

Then I get this error

graph = HeteroGraph(cipdata)
Traceback (most recent call last):

  File "/home/hojun/anaconda3/envs/geometric/lib/python3.6/site-packages/torch_geometric/data/storage.py", line 48, in __getattr__
    return self[key]

  File "/home/hojun/anaconda3/envs/geometric/lib/python3.6/site-packages/torch_geometric/data/storage.py", line 68, in __getitem__
    return self._mapping[key]

KeyError: 'number_of_nodes'


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "<ipython-input-147-5bdfc5ffc776>", line 1, in <module>
    graph = HeteroGraph(cipdata)

  File "/home/hojun/anaconda3/envs/geometric/lib/python3.6/site-packages/deepsnap/hetero_graph.py", line 94, in __init__
    self._update_tensors(init=True)

  File "/home/hojun/anaconda3/envs/geometric/lib/python3.6/site-packages/deepsnap/graph.py", line 515, in _update_tensors
    self._update_attributes()

  File "/home/hojun/anaconda3/envs/geometric/lib/python3.6/site-packages/deepsnap/graph.py", line 531, in _update_attributes
    if self.G.number_of_nodes() == 0:

  File "/home/hojun/anaconda3/envs/geometric/lib/python3.6/site-packages/torch_geometric/data/hetero_data.py", line 118, in __getattr__
    return getattr(self._global_store, key)

  File "/home/hojun/anaconda3/envs/geometric/lib/python3.6/site-packages/torch_geometric/data/storage.py", line 51, in __getattr__
    f"'{self.__class__.__name__}' object has no attribute '{key}'")

AttributeError: 'BaseStorage' object has no attribute 'number_of_nodes'

How do I easily convert pyg heterograph to deepsnap one?

I wish some detailed example code can be provided.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions