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

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.