snap-stanford / ogb

Benchmark datasets, data loaders, and evaluators for graph machine learning
https://ogb.stanford.edu
MIT License
1.89k stars 397 forks source link

AttributeError: 'GlobalStorage' object has no attribute 'adj_t' #454

Closed Aaricis closed 10 months ago

Aaricis commented 12 months ago

I loaded ogbn-arxiv, and then trained this dataset with GCN model. I encontered this error, but I donnot know why. my environment:

ogb    1.3.6
python   3.7.16
torch-geometric   2.0.4
Traceback (most recent call last):
  File "/home/CCSLab/.conda/envs/dxf-GCN-npu-test/lib/python3.7/site-packages/torch_geometric/data/storage.py", line 50, in __getattr__
    return self[key]
  File "/home/CCSLab/.conda/envs/dxf-GCN-npu-test/lib/python3.7/site-packages/torch_geometric/data/storage.py", line 70, in __getitem__
    return self._mapping[key]
KeyError: 'adj_t'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "gcn-modified-npu.py", line 62, in <module>
    train()
  File "gcn-modified-npu.py", line 43, in train
    out = model(data)
  File "/home/CCSLab/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "../model_library/models/GCNNet_ogbn.py", line 32, in forward
    x, adj_t = data.x, data.adj_t
  File "/home/CCSLab/.conda/envs/dxf-GCN-npu-test/lib/python3.7/site-packages/torch_geometric/data/data.py", line 362, in __getattr__
    return getattr(self._store, key)
  File "/home/CCSLab/.conda/envs/dxf-GCN-npu-test/lib/python3.7/site-packages/torch_geometric/data/storage.py", line 53, in __getattr__
    f"'{self.__class__.__name__}' object has no attribute '{key}'")
AttributeError: 'GlobalStorage' object has no attribute 'adj_t'
THPModule_npu_shutdown success.
weihua916 commented 10 months ago

Hi! It's likely that you did not convert COO edge_index into SparseTensor format. See here. The following should work.

import torch_geometric.transforms as T
from ogb.nodeproppred import PygNodePropPredDataset
dataset = PygNodePropPredDataset(name='ogbn-arxiv', transform=T.ToSparseTensor())