Hi,
You should change the collate_fn, something like this
import torch
from torch.utils.data import TensorDataset, DataLoader


def collate_fn(batch):
    batch = torch.cat([sample[0].unsqueeze(0) for sample in batch], dim=0)
    return batch

tensor_x = torch.tensor(Mat)      #Mat is a 2d numpy array
dataset = TensorDataset(tensor_x)
loader = DataLoader(dataset, batch_size = 8, shuffle=True, collate_fn=collate_fn)