Skip to Main Content
Programming Machine Learning
book

Programming Machine Learning

by Paolo Perrotta
March 2020
Beginner to intermediate content levelBeginner to intermediate
342 pages
8h 38m
English
Pragmatic Bookshelf
Content preview from Programming Machine Learning

Running on Convolutions

Here is a convolutional neural network for CIFAR-10—all of it:

 import​ ​numpy​ ​as​ ​np
 from​ ​keras.models​ ​import​ Sequential
 from​ ​keras.layers​ ​import​ Conv2D, Dropout, Dense
 from​ ​keras.layers​ ​import​ BatchNormalization, Flatten
 from​ ​keras.optimizers​ ​import​ Adam
 from​ ​keras.utils​ ​import​ to_categorical
 from​ ​keras.datasets​ ​import​ cifar10
 
 (X_train_raw, Y_train_raw), (X_test_raw, Y_test_raw) = cifar10.load_data()
 X_train = X_train_raw / 255
 X_test_all = X_test_raw / 255
 X_validation, X_test = np.split(X_test_all, 2)
 Y_train = to_categorical(Y_train_raw)
 Y_validation, Y_test = np.split(to_categorical(Y_test_raw), 2)
 
 model = Sequential()
 
 model.add(Conv2D(16, ...
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

Mastering Machine Learning Algorithms - Second Edition

Mastering Machine Learning Algorithms - Second Edition

Giuseppe Bonaccorso
Practical Machine Learning for Computer Vision

Practical Machine Learning for Computer Vision

Valliappa Lakshmanan, Martin Görner, Ryan Gillard

Publisher Resources

ISBN: 9781680507706Errata Page