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:
What it is stating here is that while you have some magic operations implemented, that the abstract base class has declared the methods get and len as abstract. Try adding
def get(…): pass
def len(…): pass
Not sure the method signatures. But try that and see what happens.