How to convert cifar-10 images into two single contiguous arrays? One for image and another for label?

I current ran into a problem that when using the cifar-10 dataset, I need to separate the label from the image itself, and convert them into two contiguous arrays.
For the inputs this array contains all the test images, flattened.
For the labels this array contains all the labels (non-one-hot) in order.

When using theano, each image has x,y two parameters to represent image and label.

However, it seems that Pytorch has its own way to read the cifar-10 images and I don’t know how to save the images and labels separately.

Looking forward to your suggestions.

Try this tutorial:

I think trainset and testset are each a big tensor. You can run the operations on them that you want.