When applying the trained model to the actual data, my dataset only has X but labels. I created a dataset class and then feed the dataset to a dataloader. However, the iter on the dataloader returns a list with the batch tensor as the only entry. I expect the return to be a tensor. Where did I do wrong? Below is the sample code.
class MyDataset(Dataset):
    def __init__(self, dataset):
        self.dataset = dataset
    def __getitem__(self,index):
        data = self.dataset[index]
        return data
    def __len__(self):
        return len(self.dataset)
data_tensor = torch.tensor([[1, 2, 3], [1, 2, 3], [2, 3, 1], [1, 2, 3]])
data_set = MyDataset(TensorDataset(data_tensor))
data_loader = torch.utils.data.DataLoader(data_set, batch_size=2, shuffle=False)
next(iter(data_loader))

Here is the result
[tensor([[1, 2, 3],
         [1, 2, 3]])]

I tested adding a label seq to the dataset class with the X by using TensorDataset(X, y) and then the return is a batch tensor as expected. Wondering what’s the best practice to create the dataloader when the data don’t contain labels.
I found someone has the same question on stackoverflow 89