loading an image from cifar-10 dataset

后端 未结 3 1540
南方客
南方客 2020-12-20 17:03

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:

相关标签:
3条回答
  • 2020-12-20 17:39
    single_img_reshaped = single_img.reshape(3,32,32).transpose([1, 2, 0])
    
    0 讨论(0)
  • 2020-12-20 17:44

    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.

    0 讨论(0)
  • 2020-12-20 17:57

    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 data
    data = np.reshape(data, (32,32,3), order='F' ) # Fortran-like indexing order
    plt.imshow(data)
    
    0 讨论(0)
提交回复
热议问题