Custom Dataset not accepting argument in PyTorch
I am trying to create a custom Dataset in PyTorch using this dataset. It is of the shape (X, 785), X being number of samples and each row containing the label at index 0 and 784 pixel values. This is my code :
from torch.utils.data import Dataset
def SignMNISTDataset(Dataset):

  def __init__(self, csv_file_path, mode='Train'):
    self.labels = []
    self.pixels = []
    self.mode = mode

    data = pd.read_csv(csv_file_path).values
    if self.mode == 'Train':
      self.labels = data[:,0].tolist()
      print(&quot;Training labels acquired&quot;)

    for idx in range(len(self.labels)):
      self.pixels.append(data[idx][1:].tolist())

  def __len__(self):
    return len(self.labels)

  def __getitem__(self, idx):
    pixels = self.pixels[idx]
    if self.mode == 'Train':
      labels = self.labels[idx]
      content = {&quot;pixels&quot;:pixels, &quot;label&quot;:labels}
    else:
      content = {&quot;pixels&quot;:pixels}
    return content

training_data = SignMNISTDataset('sign_mnist_train/sign_mnist_train.csv', 'Train')

On running, I get the following error :
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-46-0173199f8794&gt; in &lt;module&gt;()
     27     return content
     28 
---&gt; 29 training_data = SignMNISTDataset('sign_mnist_train/sign_mnist_train.csv', 'Train')
     30 from torch.utils.data import DataLoader
     31 

TypeError: SignMNISTDataset() takes 1 positional argument but 2 were given

Where exactly is this coming from? Is the mode argument somehow not being read during the object creation?
My end goal is to create a neural network for classifying sign characters, following this tutorial.
I tried explicitly mentioning the keyword mode during the object creation. This is what I got -
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-48-fd796c48dc67&gt; in &lt;module&gt;()
     27     return content
     28 
---&gt; 29 training_data = SignMNISTDataset('sign_mnist_train/sign_mnist_train.csv', mode='Train')

TypeError: SignMNISTDataset() got an unexpected keyword argument 'mode'


Please use
class SignMNISTDataset(Dataset):

Instead of
def SignMNISTDataset(Dataset):

