Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Deep Learning Cookbook

You're reading from   Python Deep Learning Cookbook Over 75 practical recipes on neural network modeling, reinforcement learning, and transfer learning using Python

Arrow left icon
Product type Paperback
Published in Oct 2017
Publisher Packt
ISBN-13 9781787125193
Length 330 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Indra den Bakker Indra den Bakker
Author Profile Icon Indra den Bakker
Indra den Bakker
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Programming Environments, GPU Computing, Cloud Solutions, and Deep Learning Frameworks 2. Feed-Forward Neural Networks FREE CHAPTER 3. Convolutional Neural Networks 4. Recurrent Neural Networks 5. Reinforcement Learning 6. Generative Adversarial Networks 7. Computer Vision 8. Natural Language Processing 9. Speech Recognition and Video Analysis 10. Time Series and Structured Data 11. Game Playing Agents and Robotics 12. Hyperparameter Selection, Tuning, and Neural Network Learning 13. Network Internals 14. Pretrained Models

Recognizing faces


In the previous recipe, we how to detect facial keypoints with a neural network. In the following recipe, we will show how to recognize faces using a deep neural network. By training a classifier from scratch, we get a lot of flexibility.

How to do it...

  1. As usual, let's start with importing the libraries and setting the seed:
import glob
import re
import matplotlib.pyplot as plt
import numpy as np
import cv2
from sklearn.preprocessing import LabelBinarizer
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score

from keras.models import Model
from keras.layers import Flatten, Dense, Input, GlobalAveragePooling2D, GlobalMaxPooling2D, Activation
from keras.layers import Convolution2D, MaxPooling2D
from keras import optimizers
from keras import backend as K

seed = 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')
...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime