Пример #1
0
# Load the data from disk
###############################################################################
tstart = time()

db = YouTubeFacesDB('ytfdb.h5', mean_removal=True, output_type='vector')
N = db.nb_samples
d = db.input_dim
C = db.nb_classes

print(N, 'images of size', d, 'loaded in', time()-tstart)

###############################################################################
# Split into a training set and a test set 
###############################################################################
db.split_dataset(validation_size=0.25)
X_train, y_train = db.get('train')
X_test, y_test = db.get('val')

###############################################################################
# Train a not very deep network
###############################################################################
print('Create the network...')
model = Sequential()

# Convolutional input layer with maxpooling and dropout
model.add(Convolution2D(16, 6, 6, border_mode='valid', input_shape=d))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.5))

# Fully connected with ReLU and dropout