O'Reilly logo

Python Deep Learning Cookbook by Indra den Bakker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required