January 2018
Intermediate to advanced
474 pages
10h 23m
English
The following is a small example of building a simple multilayer perceptron (covered in detail in Chapter 5) to classify handwritten digits from the MNIST set:
import kerasfrom keras.datasets import mnistfrom keras.models import Sequentialfrom keras.layers import Dense, Dropoutfrom keras.optimizers import SGDfrom keras import utilsimport numpy as np# define some hyper parametersbatch_size = 100 n_inputs = 784n_classes = 10 n_epochs = 10 # get the data(x_train, y_train), (x_test, y_test) = mnist.load_data()# reshape the two dimensional 28 x 28 pixels# sized images into a single vector of 784 pixelsx_train = x_train.reshape(60000, n_inputs)x_test = x_test.reshape(10000, n_inputs)# convert the ...
Read now
Unlock full access