- 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
- Load the cifar10 dataset:
from keras.datasets import cifar10(X_train, y_train), (X_val, y_val) = cifar10.load_data()
- Normalize the input data:
X_train = X_train.astype('float32')/255.X_val = X_val.astype('float32')/255.
- 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) ...