Created
August 19, 2018 19:12
-
-
Save ogyalcin/51fbb2750d7001c30298e27a21969729 to your computer and use it in GitHub Desktop.
Reshaping and Normalizing the MNIST Images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Reshaping the array to 4-dims so that it can work with the Keras API | |
| x_train = x_train.reshape(x_train.shape[0], 28, 28, 1) | |
| x_test = x_test.reshape(x_test.shape[0], 28, 28, 1) | |
| input_shape = (28, 28, 1) | |
| # Making sure that the values are float so that we can get decimal points after division | |
| x_train = x_train.astype('float32') | |
| x_test = x_test.astype('float32') | |
| # Normalizing the RGB codes by dividing it to the max RGB value. | |
| x_train /= 255 | |
| x_test /= 255 | |
| print('x_train shape:', x_train.shape) | |
| print('Number of images in x_train', x_train.shape[0]) | |
| print('Number of images in x_test', x_test.shape[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment