Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. C:UsersjohndAppDataLocalProgramsPythonPython35libsite-packageskeraspreprocessingimage.py:653: UserWarning: Expected input to be images (as Numpy array) following the data format convention "channels_first" (channels on axis 1), i.e. expected either 1, 3 or 4 channels on axis 1. However, it was passed an array with shape (60000, 1, 28, 28) (1 channels).
  2. ' (' + str(x.shape[self.channel_axis]) + ' channels).')
  3.  
  4. from keras.datasets import mnist
  5. from keras.preprocessing.image import ImageDataGenerator
  6. from matplotlib import pyplot
  7. from keras import backend as K
  8. K.set_image_dim_ordering('th')
  9. # load data
  10. (X_train, y_train), (X_test, y_test) = mnist.load_data()
  11. # reshape to be [samples][pixels][width][height]
  12. X_train = X_train.reshape(X_train.shape[0], 1, 28, 28)
  13. X_test = X_test.reshape(X_test.shape[0], 1, 28, 28)
  14. # convert from int to float
  15. X_train = X_train.astype('float32')
  16. X_test = X_test.astype('float32')
  17. # define data preparation
  18. datagen = ImageDataGenerator(zca_whitening=True)
  19. # fit parameters from data
  20. datagen.fit(X_train)
  21. # configure batch size and retrieve one batch of images
  22. for X_batch, y_batch in datagen.flow(X_train, y_train, batch_size=9):
  23. # create a grid of 3x3 images
  24. for i in range(0, 9):
  25. pyplot.subplot(330 + 1 + i)
  26. pyplot.imshow(X_batch[i].reshape(28, 28), cmap=pyplot.get_cmap('gray'))
  27. # show the plot
  28. pyplot.show()
  29. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement