Why plt.imshow() doesn't display the image?

前端 未结 4 2168
予麋鹿
予麋鹿 2020-12-13 12:06

I am a newbie to keras, and when I tried to run my first keras program on my linux, something just didn\'t go as I wish. Here is my python code:

import numpy         


        
4条回答
  •  余生分开走
    2020-12-13 12:30

    The solution was as simple as adding plt.show() at the end of the code snippet:

    import numpy as np
    np.random.seed(123)
    from keras.models import Sequential
    from keras.layers import Dense, Dropout, Activation, Flatten
    from keras.layers import Convolution2D, MaxPooling2D
    from keras.utils import np_utils
    from keras.datasets import mnist
    (X_train,y_train),(X_test,y_test) = mnist.load_data()
    print X_train.shape
    from matplotlib import pyplot as plt
    plt.imshow(X_train[0])
    plt.show()
    

提交回复
热议问题