In my customized dataset there are only feature matrices and adjacency matrices.The feature matrix is a 4000×3000 one-dimensional tensor,and edge_index is torch.Size([2, 18708])
My code is :
from torch_geometric.data import Data
data = Data(x=features,edge_index=edge_index.t().contiguous())
from torch_geometric.data import DataLoader
loader = DataLoader(data,batch_size=128,shuffle=True)
for batch in loader:
batch
bug is :
File ~/miniconda3/envs/spacel/lib/python3.8/site-packages/torch/utils/data/dataloader.py:521, in _BaseDataLoaderIter.__next__(self)
519 if self._sampler_iter is None:
520 self._reset()
--> 521 data = self._next_data()
522 self._num_yielded += 1
523 if self._dataset_kind == _DatasetKind.Iterable and
524 self._IterableDataset_len_called is not None and
525 self._num_yielded > self._IterableDataset_len_called:
File ~/miniconda3/envs/spacel/lib/python3.8/site-packages/torch/utils/data/dataloader.py:561, in _SingleProcessDataLoaderIter._next_data(self)
559 def _next_data(self):
560 index = self._next_index() # may raise StopIteration
--> 561 data = self._dataset_fetcher.fetch(index) # may raise StopIteration
562 if self._pin_memory:
563 data = _utils.pin_memory.pin_memory(data)
File ~/miniconda3/envs/spacel/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py:49, in _MapDatasetFetcher.fetch(self, possibly_batched_index)
47 def fetch(self, possibly_batched_index):
48 if self.auto_collation:
...
File ~/miniconda3/envs/spacel/lib/python3.8/site-packages/torch_geometric/data/storage.py:111, in BaseStorage.__getitem__(self, key)
110 def __getitem__(self, key: str) -> Any:
--> 111 return self._mapping[key]
KeyError: 0
Why is there this bug?And how to fix it.
New contributor
luxin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.