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, ... |
Get Programming Machine Learning now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.