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. We start by importing all libraries as follows:
from keras.models import Sequentialfrom keras.layers import Dense, Dropout, Activation, Flattenfrom keras.layers import Conv2D, MaxPooling2Dfrom keras.optimizers import Adamfrom sklearn.model_selection import train_test_splitfrom keras.utils import to_categoricalfrom keras.callbacks import EarlyStopping, TensorBoard, ModelCheckpointfrom keras.datasets import cifar10
  1. Next, we load the Cifar10 dataset and pre-process it:
(X_train, y_train), (X_test, y_test) = cifar10.load_data()validation_split = 0.1X_train, X_val, y_train, y_val = train_test_split(X_train, y_train, test_size=validation_split, random_state=SEED)X_train = X_train.astype('float32')X_train /=255.X_val = X_val.astype('float32') ...

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