dmlc / dgl

Python package built to ease deep learning on graph, on top of existing DL frameworks.
http://dgl.ai
Apache License 2.0
13.25k stars 2.99k forks source link

Can't get attribute 'DGLHeteroGraph' on <module 'dgl.heterograph' from '/usr/local/lib/python3.10/dist-packages/dgl/heterograph.py'> #6062

Open 22842219 opened 1 year ago

22842219 commented 1 year ago

❓ Questions and Help

Hi,

I was trying to load a constructed dgl graph. but got the following error. Any advice for this? Thanks.

Can't get attribute 'DGLHeteroGraph' on <module 'dgl.heterograph' from '/usr/local/lib/python3.10/dist-packages/dgl/heterograph.py'>

czkkkkkk commented 12 months ago

Hi @22842219, could you follow the bug report template to provide more details?

paoxiaode commented 12 months ago

meet the same problem when using MNIST dataset at https://data.dgl.ai/dataset/benchmarking-gnns/MNIST.pkl

how to reproduce

curl https://data.dgl.ai/dataset/benchmarking-gnns/MNIST.pkl -o MNIST.pkl -J -L -k

with open("MNIST.pkl","rb") as f:
          f = pickle.load(f)

error

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    f = pickle.load(f)
AttributeError: Can't get attribute 'DGLHeteroGraph' on <module 'dgl.heterograph' from '/home/ubuntu/.local/lib/python3.8/site-packages/dgl/heterograph.py'>
czkkkkkk commented 12 months ago

This is a known issue. Please refer to https://github.com/dmlc/dgl/issues/5574.

paoxiaode commented 12 months ago

If you use the new version of DGL, you can dump a new graph pkl file.

leaves520 commented 11 months ago

how to deal with this problem?? @paoxiaode , looking for your reply, thx.

paoxiaode commented 11 months ago

how to deal with this problem?? @paoxiaode , looking for your reply, thx.

@leaves520 This problem is due to the pkl file being dumped under an older version of DGL.

If you want to use the PATTERN, CLUSTER dataset, you can refer to https://github.com/dmlc/dgl/blob/master/python/dgl/data/pattern.py, they are now supported by DGL.

If you want to use the not DGL built-in dataset dataset(CIFAR 10 or MNIST), you can refer to https://github.com/graphdeeplearning/benchmarking-gnns/blob/master/data/superpixels/prepare_superpixels_MNIST.ipynb, use the code like below to re-dump the dataset pkl file

import pickle
import time

from data.superpixels import SuperPixDatasetDGL 

from data.data import LoadData
from torch.utils.data import DataLoader
from data.superpixels import SuperPixDataset

DATASET_NAME = 'MNIST'
dataset = SuperPixDatasetDGL(DATASET_NAME) 

with open('data/superpixels/MNIST.pkl','wb') as f:
        pickle.dump([dataset.train,dataset.val,dataset.test],f)
github-actions[bot] commented 10 months ago

This issue has been automatically marked as stale due to lack of activity. It will be closed if no further activity occurs. Thank you

GARV-k commented 3 weeks ago

How to solve this for ZINC dataset.