loading an image from cifar-10 dataset loading an image from cifar-10 dataset numpy numpy

loading an image from cifar-10 dataset


I used

single_img_reshaped = np.transpose(np.reshape(single_img,(3, 32,32)), (1,2,0))

to get the correct format in my program.


Since Python uses the default C-like indexing order (row-major order), it can be forced to work in column-major order:

import numpy as npimport matplotlib.pyplot as plt# I assume you have loaded your data into x_train (see some tutorial)data = x_train[0, :] # get a row datadata = np.reshape(data, (32,32,3), order='F' ) # Fortran-like indexing orderplt.imshow(data)


single_img_reshaped = single_img.reshape(3,32,32).transpose([1, 2, 0])