How to do it...

  1. Import all necessary libraries:
import numpy as npfrom matplotlib import pyplot as pltfrom keras.utils import np_utilsfrom keras.models import Sequentialfrom keras.layers.core import Dense, Dropout, Activation, Flattenfrom keras.callbacks import EarlyStoppingfrom keras.layers import Conv2D, MaxPooling2Dfrom keras.layers.normalization import BatchNormalization
  1. Load the cifar10 dataset:
from keras.datasets import cifar10(X_train, y_train), (X_val, y_val) = cifar10.load_data()
  1. Normalize the input data:
X_train = X_train.astype('float32')/255.X_val = X_val.astype('float32')/255.
  1. One-hot encode the labels:
n_classes = 10y_train = np_utils.to_categorical(y_train, n_classes)y_val = np_utils.to_categorical(y_val, n_classes) ...

Get Python Deep Learning Cookbook 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.