Converting two Numpy data sets into a particularr PyTorch data set
I want to play around with a neural network that recognizes handwritten numbers. I found some of these on the web which use PyTorch, however they seem to download the data from the MNIST website in a particular format. My data is, however, available as follows:

with np.load('prediction-challenge-01-data.npz') as fh:
     data_x = fh['data_x']
     data_y = fh['data_y']


Where data_x is the training data and data_y are the labels of the pictures. I want these data sets to be in the same format as trainloader as shown below:

trainset = datasets.MNIST('/data/mnist', download=True, train=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=64, shuffle=True)


Where trainloader already has the training set data_x and labels data_y together in one set.

Is there any way to do this? 

Edit: Shapes of data_x and data_y:

In [1]:  data_x.shape
Out[2]: (20000, 1, 28, 28)

In [5]:  data_y.shape
Out[7]: (20000,)


You can easily create your own dataset. Just inherit from torch.utils.data.Dataset and implement 
__getitem__ at the very least:
Here is a quick and dirty example to get you going:

class YourOwnDataset(torch.utils.data.Dataset):
    def __init__(self, input_file_path, transformations) :
        super().__init__()
        self.path = input_file_path
        self.transforms = transformations

        with np.load(self.path) as fh:
            # I assume fh['data_x'] is a list you get the idea  
            self.data = fh['data_x']
            self.labels = fh['data_y']


    # in getitem, we retrieve one item based on the input index
    def __getitem__(self, index):
        data = self.data[index]
        # based on the loss you chose and what you have in mind, 
        # you can transform you label, here I assume they are 
        # integer numbers (like, 1, 3, etc as labels used for classification)
        label = self.labels[index]
        img = convert/reshape your data into img
        img = self.transforms(img)
        return img, labels

    def __len__(self):
        return len(self.data)



and you can create your dataset like : 

from torchvision import transforms

# add any number of transformations you like, I just added ToTensor()
transformations = transforms.Compose([transforms.ToTensor()])

trainset = YourOwnDataset('prediction-challenge-01-data.npz', transformations )
trainloader = torch.utils.data.DataLoader(trainset, batch_size=64, shuffle=True)

