16.03.2021 Views

Advanced Deep Learning with Keras

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6

if (i + 1) % save_interval == 0:

if (i + 1) == train_steps:

show = True

else:

show = False

generators = (gen0, gen1)

plot_images(generators,

noise_params=noise_params,

show=show,

step=(i + 1),

model_name=model_name)

# save the modelis after training generator0 & 1

# the trained generator can be reloaded for

# future MNIST digit generation

gen1.save(model_name + "-gen1.h5")

gen0.save(model_name + "-gen0.h5")

Generator outputs of StackedGAN

After training the StackedGAN for 10,000 steps, the Generator 0

and Generator 1

models

are saved on files. Stacked together, Generator 0

and Generator 1

can synthesize fake

images conditioned on label and noise codes, z 0

and z 1

.

The StackedGAN generator can be qualitatively validated by:

1. Varying the discrete labels from 0 to 9 with both noise codes, z 0

and z 1

sampled from a normal distribution with a mean of 0.5 and standard

-deviation of 1.0. The results are shown in Figure 6.2.9. We're able to see

that the StackedGAN discrete code can control the digits produced by

the generator:

python3 stackedgan-mnist-6.2.1.py

--generator0=stackedgan_mnist-gen0.h5

--generator1=stackedgan_mnist-gen1.h5 --digit=0

to

python3 stackedgan-mnist-6.2.1.py

--generator0=stackedgan_mnist-gen0.h5

--generator1=stackedgan_mnist-gen1.h5 --digit=9

[ 197 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!