Linked Questions

Popular Questions

I try to establish a class that inherit from Dataset of torch_geometric, the codes are:

from import Data, Dataset
import numpy as np

class GraphTimeSeriesDataset(Dataset):
    def __init__(self):
        # Initialize your dataset here

    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.

  • Successful environment description: here
  • Failed environment description: here

My questions:

  1. Is this error caused by environment or codes itself?
  2. How should I adjust my codes to avoid this kind of error?
  3. What's possible root cause?

Related Questions