ptrblck:

x = torch.arange(100) y = torch.arange(100) dataset = torch.utils.data.TensorDataset(x, y) loader = torch.utils.data.DataLoader( dataset, shuffle=True, batch_size=2 ) for data, target in loader: print((data==target).all())


I am really thankful for your response, Let me explain further what I am doing so that you have the full picture, I am using a sequence to sequence model on time series data to achieve two tasks concurrently: forecast the next time step and predict the corresponding label of the input sequence.  So, for my model for each input sequence I have two targets:(shifted version of the input and the truth label of the input). at the end of the day, I need the input tensor(n) to be similar target_tensor(n-1)  as I am shifting by step 1.
Here is the code:
Class Cmapps_train_Dataset(Dataset):
def __init__(self, data_identifier,data_dir,win_size):
    """Reads source and target sequences from processing file ."""
    x_train, x_test,y_train,y_test = process_data(data_dir,data_identifier,win_size)
    self.input_tensor=(torch.from_numpy(x_train)).float()
    self.target_tensor=roll(self.input_tensor,-1,0,0)
    self.label=(torch.from_numpy(y_train)).float()
    self.num_total_seqs = len(self.input_tensor)

def __getitem__(self, index):
    """Returns one data pair (source and target)."""
    src_seq = self.input_tensor[index]
    trg_seq = self.target_tensor[index]
    labels = self.label[index]
    return src_seq, trg_seq,labels

def __len__(self):
    return self.num_total_seqs

data_dir= r"…/…/Deep Learning for RUL/data/"
data_identifier=‘FD001’
win_size=30;batch_size=10;
shuffle_stats;drop_last=True
train_data=Cmapps_train_Dataset(data_identifier,data_dir,win_size)
train_dl = DataLoader(train_data,batch_size=batch_size, shuffle=shuffle_stats,drop_last=drop_last)
=====
sample=next(iter(train_dl))
input_tesnor=sample[0]
target_tensor=sample[1]
for n in range(1,10):
print((input_tesnor[n]==target_tensor[n-1]).all())
===========
Results:
with Shuffle=False:
tensor(True)
tensor(True)
tensor(True)
tensor(True)
tensor(True)
tensor(True)
tensor(True)
tensor(True)
tensor(True)
=====
Results with shuffle=True :
tensor(False)
tensor(False)
tensor(False)
tensor(False)
tensor(False)
tensor(False)
tensor(False)
tensor(False)
tensor(False)