Reputation: 153
In my training dataset, I am trying to call a function that is charge in my training dataset which I am trying to call that function but I am getting an error that I can't call my function I don't understand why it's not moving previously was working perfectly.
Here is my code
class TrainDataset(Dataset):
def __init__(self,x,y):
self.x = x
self.y = y
def __getitem__(self,index):
# Get one item from the dataset
return self.x[index], self.y[index]
def __len__(self):
return len(self.x)
And I am trying to call it by my own parameters.
TrainDataset = TrainDataset(x,y)
Now I am facing this error.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-23-18c28e7d7416> in <module>
----> 1 TrainDataset = TrainDataset(x,y)
TypeError: 'TrainDataset' object is not callable
Upvotes: 1
Views: 3539
Reputation: 191844
You reassigned the class to a variable
TrainDataset = TrainDataset(x,y)
Then that variable is not callable, so you can't make that class anymore
Variables shouldn't start with capital letters, anyway
Upvotes: 4