IndexError: too many indices for tensor of dimension 2
here is the dataset:
class price_dataset(Dataset):
    def __init__(self, transform=None):
        xy = pd.read_csv('data_balanced_full.csv')

        self.n_samples = xy.shape[0]

        xy = xy.to_numpy()
        self.x_data = torch.from_numpy(xy[:, 7:].astype(np.float32))
        self.y_data = torch.from_numpy(xy[:, 6].astype(np.float32))
        self.transform = transform

    def __getitem__(self, index):
        x = self.x_data[index]
        y = self.y_data[index]

        sample = {'data': x, 'label': y}
        if self.transform:
            sample = self.transform(sample)

        return sample

    # we can call len(dataset) to return the size
    def __len__(self):
        return self.n_samples

and I'm trying to split the dataset into testing and training:
dataset_normalized = price_dataset(transform=transforms.ToTensor())
train_dataset, test_dataset = train_test_split(dataset_normalized['data'], dataset_normalized['label'], test_size=0.10, random_state=0)

but I'm getting this error:
IndexError: too many indices for tensor of dimension 2


'data' and 'label' are not indices but keys of a dictionnary. This dictionary is accessible and calling __getitem__ as follows : dataset_normalized[idx] with idx an integer.
Moreover, you cannot invoke your transformation directly on a dictionary. You should call it on sample['data'] instead.
I advise you to carefully read this example of the PyTorch documentation which is very nice.
