faster-rcnn.pytorch
faster-rcnn.pytorch copied to clipboard
AttributeError: 'Tensor' object has no attribute 'index'
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.