Can not get all data from __getitem__

Hi, I normalize the 100 data, randomlly spilit to train set and test set, but I seem like I only get 1 data from getitem function. Appreciate if anyone can give a hint. Here are my codes:

def __getitem__(self, idx):
    if not isinstance(idx, int):
        idx = idx.item()
    else:
        for idx in (self.data):
            x = self.normalized_data[idx,:-1].astype('float32')
            y = self.normalized_data[idx, -1].astype('float32')
            sample = {"input": x, "label": y}
    return sample

class Data_Loaders():
def init(self, batch_size):
self.nav_dataset = Nav_Dataset()
split = torch.utils.data.random_split(self.nav_dataset, [80, 20])
self.train_loader = split[0]
self.test_loader = split[1]

I got full list of train_loader and test_loader, but it does not show up here:

batch_size = 16
data_loaders = Data_Loaders(batch_size)

for idx, sample in enumerate(data_loaders.train_loader):
train_input, train_label = sample[“input”], sample[“label”]

Result:
print(list(sample[“input”]))

[1.0, 0.8850779, 0.69589293, 0.89152443, 1.0, 0.5]

Based on your code snippet, it doesn’t seem like you are passing your Dataset into torch.utils.data.DataLoader? You should import DataLoader and pass split[0] into it (along with any additional parameters).