Why my custom dataset gives attribute error?
my initial data was like this
My data is a pandas dataframe with columns 'title' and 'label'. I want to make a custom dataset with this. so I made the dataset like below. I'm working on google colab
class newsDataset(torch.utils.data.Dataset):
  def __init__(self,train=True,transform=None):
    if train:
      self.file = ttrain
    else:
      self.file= ttest
    
    self.text_list = self.file['title'].values.tolist()
    self.class_list=self.file['label'].values.tolist()

  def __len__(self):
    return len(self.text_list)
  
  def __getitem__(self,idx):
    label = self.class_list[idx]
    text = self.text_list[idx]

    if self.transform is not None:
      text=self.transform(text)
      
    return label, text

and this is how I call the dataloader
trainset=newsDataset()
train_iter = DataLoader(trainset)
iter(train_iter).next()

and it gives
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
&lt;ipython-input-153-9872744bc8a9&gt; in &lt;module&gt;()
----&gt; 1 iter(train_iter).next()

5 frames
/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataset.py in __getattr__(self, attribute_name)
     81             return function
     82         else:
---&gt; 83             raise AttributeError
     84 
     85     @classmethod

AttributeError: 

There was no exact error message. can anybody help me?

Please add the following missing line to your __init__ function:
self.transform = transform

