GANs training on CelebA report
First sweep
Configuration
The first sweep was a random search over (about) 20 runs, with the following configuration
parameters_dic = {
'epochs':{'value':5},
'batch_size':{'values':[64,128]},
'latent_dim':{'values':[50,100,200]},
'gen_struc':{'values':[0,1,2]},
'disc_struc':{'values':[0,1,2]},
}
With 'gen_struc' and 'dic_struc' being 3 different configurations of the generatorand the discriminator, they are as follow
def define_discriminator(structure,in_shape=INPUT_SHAPE) :
model = Sequential()
if structure == 0 :
model.add(Conv2D(128, (3,3), strides=(2,2), padding = 'same', input_shape=in_shape))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2D(128, (3,3), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
model.add(Flatten())
model.add(Dropout(0.4))
model.add(Dense(1,activation="sigmoid"))
elif structure == 1 :
model.add(Conv2D(256, (3,3), strides=(2,2), padding = 'same', input_shape=in_shape))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2D(256, (3,3), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
model.add(Flatten())
model.add(Dropout(0.4))
model.add(Dense(1,activation="sigmoid"))
elif structure == 2 :
model.add(Conv2D(128, (3,3), strides=(2,2), padding = 'same', input_shape=in_shape))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2D(128, (3,3), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2D(128, (3,3), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
model.add(Flatten())
model.add(Dropout(0.4))
model.add(Dense(1,activation="sigmoid"))
opt = Adam(learning_rate=0.0002, beta_1=0.5)
model.compile(loss="binary_crossentropy", optimizer=opt, metrics=["accuracy"])
return model
And
def define_generator(structure,latent_dim): #latent_dim is the dimension of the latent vector (e.g., 100)
model = Sequential()
if structure == 0 :
n_nodes = 64 * 28 * 32
model.add(Dense(n_nodes, input_dim=latent_dim)) #Dense layer so we can work with 1D latent vector
model.add(LeakyReLU(alpha=0.2))
model.add(Reshape((28, 32, 64)))
model.add(Conv2DTranspose(64, (4,4), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2DTranspose(64, (4,4), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
elif structure == 1 :
n_nodes = 512 * 28 * 32
model.add(Dense(n_nodes, input_dim=latent_dim)) #Dense layer so we can work with 1D latent vector
model.add(LeakyReLU(alpha=0.2))
model.add(Reshape((28, 32, 512)))
model.add(Conv2DTranspose(256, (4,4), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2DTranspose(128, (4,4), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
elif structure == 2 :
n_nodes = 128 * 14 * 16
model.add(Dense(n_nodes, input_dim=latent_dim)) #Dense layer so we can work with 1D latent vector
model.add(LeakyReLU(alpha=0.2))
model.add(Reshape((14,16, 128)))
model.add(Conv2DTranspose(128, (4,4), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2DTranspose(64, (4,4), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
model.add(Conv2DTranspose(64, (4,4), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
# generate
model.add(Conv2D(3, (8,8), activation='tanh', padding='same'))
return model
Measures
Durations
The goal of the sweep was not to make conveincing pictures, but rather to determine which structure is the more efficient, meaning provides the highest quality pictures with the lowest amount of training time.
We can see on the both graph that the discriminator sctructure is the one impacting the training time the most. At least, with the 3 structure I've chosen for the discriminator, the structure 1 is the only one having a significant impact on the duration of the epoch. Wereas the structures I've choosen for the generator don't seem to impact the training time so much.
Samples
To measure the performances of the run, I will give each run a point if, on the 5th epoch, 3 out of 5 pictures have the following :
- Clear eyes
- Clear mouth
- Distinction between face and background
- Realistic face tone