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. As usual, let's start with importing the libraries and setting the seed:
import globimport reimport matplotlib.pyplot as pltimport numpy as npimport cv2from sklearn.preprocessing import LabelBinarizerfrom sklearn.model_selection import train_test_splitfrom sklearn.metrics import accuracy_scorefrom keras.models import Modelfrom keras.layers import Flatten, Dense, Input, GlobalAveragePooling2D, GlobalMaxPooling2D, Activationfrom keras.layers import Convolution2D, MaxPooling2Dfrom keras import optimizersfrom keras import backend as Kseed = 2017
  1. In the following step, we will load the data and output some example images to get an idea of the data:
 DATA_DIR = 'Data/lfw/'images = glob.glob(DATA_DIR + '*/*.jpg')plt.figure(figsize=(10, ...

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