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