I try to establish a class that inherit from Dataset
of torch_geometric
, the codes are:
from torch_geometric.data import Data, Dataset
import numpy as np
class GraphTimeSeriesDataset(Dataset):
def __init__(self):
# Initialize your dataset here
pass
def __len__(self):
# Return the total number of samples in the dataset
return len(self.data_list)
def __getitem__(self, idx):
# Return the data sample at the given index
return self.data_list[idx]
dataset = GraphTimeSeriesDataset()
And the error message:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[4], line 17
13 def __getitem__(self, idx):
14 # Return the data sample at the given index
15 return self.data_list[idx]
---> 17 dataset = GraphTimeSeriesDataset()
TypeError: Can't instantiate abstract class GraphTimeSeriesDataset with abstract methods get, len
I'm not sure what's the root cause of this error, because I can operate these codes in other environment.
My questions:
- Is this error caused by environment or codes itself?
- How should I adjust my codes to avoid this kind of error?
- What's possible root cause?