Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert PyG heterograph to DeepSnap heterograph? #43

Open
Jeriousman opened this issue Feb 25, 2022 · 0 comments
Open

How to convert PyG heterograph to DeepSnap heterograph? #43

Jeriousman opened this issue Feb 25, 2022 · 0 comments

Comments

@Jeriousman
Copy link

Jeriousman commented Feb 25, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant