How to do it...

Face generation is implemented in code as follows (the code file is available as Face_generation.ipynb in GitHub):

  1. Download the dataset. The recommended dataset to be downloaded and the associated code is provided in GitHub. A sample of images is as follows:

  1. Define the model architecture:
def generator():    model = Sequential()    model.add(Dense(input_dim=100, output_dim=1024))    model.add(Activation('tanh'))    model.add(Dense(128*7*7))    model.add(BatchNormalization())    model.add(Activation('tanh'))    model.add(Reshape((7, 7, 128), input_shape=(128*7*7,)))    model.add(UpSampling2D(size=(2, 2))) model.add(Conv2D(64, (5, 5), padding='same')) ...

Get Neural Networks with Keras 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.