How to do it...

  1. We start with importing all necessary libraries and setting the seed, as follows:
import pandas as pdimport numpy as npimport matplotlib.pyplot as pltfrom sklearn.model_selection import train_test_splitimport tensorflow as tfSEED = 2017
  1. Next, we load the dataset and output some numbers:
DIR = 'Data/faces/'training_file = pd.read_csv(DIR + 'training.csv')cols = training_file.columns[:-1]training_file['Image'] = training_file['Image'].apply(lambda Image: np.fromstring(Image, sep=' '))training_file = training_file.dropna()
  1. Before proceeding, we need to reshape and normalize the data:
img_cols = 96img_rows = 96img_channels = 1n_labels = 30 # 15 times x, y pairsX = np.vstack(training_file['Image'])X = X.reshape(-1, img_cols, ...

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.