-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Description
I need a guide on how to resolve this bug:
label_idx = labels.index(label) # Convert label to an index
AttributeError: 'Tensor' object has no attribute 'index'
Pycharm referenced this class to be the sources of the error:
class SpeedDataset(Dataset):
def init(self, data):
self.data = data
def __len__(self):
return len(self.data)
def __getitem__(self, idx):
speed = self.data.iloc[idx]['speeds']
label = self.data.iloc[idx]['label']
label_idx = labels.index(label) # Convert label to an index
return torch.tensor(speed, dtype=torch.float32), torch.tensor(label_idx, dtype=torch.long)
Please, I need a guide to resolve this issue.
Metadata
Metadata
Assignees
Labels
No labels