Loading An Image From Cifar-10 Dataset
I am using cifar-10 dataset for my training my classifier. I have downloaded the dataset and tried to display am image from the dataset. I have used the following code: from six.mo
Solution 1:
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.
Solution 2:
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 np
import 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 order
plt.imshow(data)
Solution 3:
single_img_reshaped = single_img.reshape(3,32,32).transpose([1, 2, 0])
Post a Comment for "Loading An Image From Cifar-10 Dataset"