Skip to Content
Python Deep Learning - Second Edition
book

Python Deep Learning - Second Edition

by Ivan Vasilev, Daniel Slater, Gianmario Spacagna, Peter Roelants, Valentino Zocca
January 2019
Intermediate to advanced
386 pages
11h 13m
English
Packt Publishing
Content preview from Python Deep Learning - Second Edition

Classifying handwritten digits with a convolutional network

In the third chapter, we introduced a simple neural network to classify digits using Keras and we got 96% accuracy. We could improve this with some tricks (more hidden neurons, for example), but let's try with a simple CNN instead:

  1. First, we'll do the imports. We'll also set the random seed:
# for reproducibilityfrom numpy.random import seedseed(1)from tensorflow import set_random_seedset_random_seed(1)
  1. Then, we'll do the imports, including convolutional and max pooling layers, as shown in the following example:
from keras.datasets import mnistfrom keras.models import Sequentialfrom keras.layers import Dense, Activationfrom keras.layers import Convolution2D, MaxPooling2Dfrom ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Deep Learning

Python Deep Learning

Valentino Zocca, Gianmario Spacagna, Daniel Slater, Peter Roelants

Publisher Resources

ISBN: 9781789348460Supplemental Content