Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import keras
- from keras.datasets import mnist
- from keras.models import Sequential
- from keras.layers import Dense, Dropout, LeakyReLU, Conv2D
- from keras.optimizers import RMSprop
- from keras import backend as K
- K.tensorflow_backend._get_available_gpus()
- from matplotlib.pyplot import imshow
- import numpy as np
- from tensorflow.examples.tutorials.mnist import input_data
- # 讀入 MNIST
- (x_train, y_train), (x_test, y_test) = mnist.load_data()
- # the data, shuffled and split between train and test sets
- x_train = x_train.reshape(60000 , 784)
- x_test = x_test.reshape(10000, 784)
- x_train = x_train.astype('float32')
- x_test = x_test.astype('float32')
- x_train /= 255
- x_test /= 255
- # convert class vectors to binary class matrices
- num_classes = 10
- y_train = keras.utils.to_categorical(y_train, num_classes)
- y_test = keras.utils.to_categorical(y_test, num_classes)
- print(x_train.shape, 'train samples')
- print(x_test.shape, 'test samples')
- print(y_train.shape, 'train labels')
- print(y_test.shape, 'test labels')
- # modeling
- ________________________________________________
- ________________________________________________
- ________________________________________________
- ________________________________________________
- # training
- ________________________________________________
- # fitting
- ________________________________________________
- # testing
- ________________________________________________
- ________________________________________________
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement