Iterating through data loader returning dimension error

Hi, i have been trying for days to join my training data and labels together but kept on meeting several errors but this error is quite difficult for me to understand, so if anyone could please shed some light i would be most thankful . I’m trying to Iterate through a concatenated data set that contains my train data and labels but i keep on encountering this error. Train_data dim = [27455, 1, 28, 28] and train_labels dim = [27455].

Could you post the code of your Dataset implementation?
It seems you would like to return both the data and target as one tensor?

The usual approach would be to return these tensors separately, as they might have a different number of dimensions and shapes:

def __getitem__(self, index):
    return data, target
train = pd.read_csv("../datasets/sign-language-mnist/sign_mnist_train/sign_mnist_train.csv") test = pd.read_csv("../datasets/sign-language-mnist/sign_mnist_test/sign_mnist_test.csv") train_labels = train.pop('label').values test_labels = test.pop('label').values

train_data = train.values
test_data = train.values

train_data, test_data = np.array(train_data, dtype=np.float32), np.array(test_data, dtype=np.float32)
train_labels, test_labels = np.array(train_labels, dtype=np.float32), np.array(test_labels, dtype=np.float32)
train_data, test_data = train_data.reshape((-1,1,28,28)), test_data.reshape((-1,1,28,28))

train_data = torch.from_numpy(train_data)
train_labels = torch.from_numpy(train_labels)
test_data = torch.from_numpy(test_data)
test_labels = torch.from_numpy(test_labels)

train_data =
test_data =

train_data, train_labels =,
test_data, test_labels =,

train_loader =[train_data, train_labels])
test_loader =[test_data, test_labels])

train_loader =,
shuffle=True, batch_size=32)
test_loader =,
shuffle=True, batch_size=32)