I created a dataset and to creat a dataloader with Pytorch. I have the following problem, I would like to create a dataloader with only the features data and y_vector. As I apply torch.utils.data.random_split if I want the nth element of the test_dataset if I don’t include z_vector I can’t understand which element of z_vector I have to take. I do not have to give in input z_vector to the network and it seems useless to include it in the dataloader. How to do?
class Dataset(): def __init__(self, X_np_array, y_np_vector,z_np_vector, transform=None): self.transform = transform self.data = torch.Tensor(X_np_array[:,None, :, :]) self.y_vector = torch.Tensor(y_np_vector) self.z_np_vector= torch.Tensor(z_np_vector) def __getitem__(self, index): return self.data[index], self.y_vector[index],self.z_np_vector[index] def __len__(self): return len(list(self.data)) def train_test_split(self,dataset,splitting_percentage): torch.manual_seed(int(1996)) train_dim = int(len(dataset)*splitting_percentage) test_dim = len(dataset)-train_dim train_dataset, test_dataset = torch.utils.data.random_split(dataset, [train_dim, test_dim]) return train_dataset, test_dataset