Advanced Deep Learning with Keras

fourpersent2020
from fourpersent2020 More from this publisher
16.03.2021 Views

Chapter 6# plot generator images on a periodic basisgan.plot_images(generator,noise_input=noise_input,noise_label=noise_label,noise_codes=[noise_code1, noise_code2],show=show,step=(i + 1),model_name=model_name)# save the model after training the generator# the trained generator can be reloaded for# future MNIST digit generationgenerator.save(model_name + ".h5")Generator outputs of InfoGANSimilar to all previous GANs that have been presented to us, we've trained InfoGANfor 40,000 steps. After the training is completed, we're able to run the InfoGANgenerator to generate new outputs using the model saved on the infogan_mnist.h5file. The following validations are conducted:1. Generate digits 0 to 9 by varying the discrete labels from 0 to 9. Bothcontinuous codes are set to zero. The results are shown in Figure 6.1.5. Wecan see that the InfoGAN discrete code can control the digits produced bythe generator:python3 infogan-mnist-6.1.1.py --generator=infogan_mnist.h5--digit=0 --code1=0 --code2=0topython3 infogan-mnist-6.1.1.py --generator=infogan_mnist.h5--digit=9 --code1=0 --code2=02. Examine the effect of the first continuous code to understand which attributehas been affected. We vary the first continuous code from -2.0 to 2.0 for digits0 to 9. The second continuous code is set to 0.0. Figure 6.1.6 shows that thefirst continuous code controls the thickness of the digit:python3 infogan-mnist-6.1.1.py --generator=infogan_mnist.h5--digit=0 --code1=0 --code2=0 --p13. Similar to the previous step, but instead focusing more on the secondcontinuous code. Figure 6.1.7 shows that the second continuous codecontrols the rotation angle (tilt) of the writing style:[ 177 ]

Disentangled Representation GANspython3 infogan-mnist-6.1.1.py --generator=infogan_mnist.h5--digit=0 --code1=0 --code2=0 --p2Figure 6.1.5: The images generated by the InfoGAN as the discrete codeis varied from 0 to 9. Both continuous codes are set to zero.Figure 6.1.6: The images generated by InfoGAN as the first continuous code is varied from -2.0 to 2.0 for digits0 to 9. The second continuous code is set to zero. The first continuous code controls the thickness of the digit.[ 178 ]

Chapter 6

# plot generator images on a periodic basis

gan.plot_images(generator,

noise_input=noise_input,

noise_label=noise_label,

noise_codes=[noise_code1, noise_code2],

show=show,

step=(i + 1),

model_name=model_name)

# save the model after training the generator

# the trained generator can be reloaded for

# future MNIST digit generation

generator.save(model_name + ".h5")

Generator outputs of InfoGAN

Similar to all previous GANs that have been presented to us, we've trained InfoGAN

for 40,000 steps. After the training is completed, we're able to run the InfoGAN

generator to generate new outputs using the model saved on the infogan_mnist.h5

file. The following validations are conducted:

1. Generate digits 0 to 9 by varying the discrete labels from 0 to 9. Both

continuous codes are set to zero. The results are shown in Figure 6.1.5. We

can see that the InfoGAN discrete code can control the digits produced by

the generator:

python3 infogan-mnist-6.1.1.py --generator=infogan_mnist.h5

--digit=0 --code1=0 --code2=0

to

python3 infogan-mnist-6.1.1.py --generator=infogan_mnist.h5

--digit=9 --code1=0 --code2=0

2. Examine the effect of the first continuous code to understand which attribute

has been affected. We vary the first continuous code from -2.0 to 2.0 for digits

0 to 9. The second continuous code is set to 0.0. Figure 6.1.6 shows that the

first continuous code controls the thickness of the digit:

python3 infogan-mnist-6.1.1.py --generator=infogan_mnist.h5

--digit=0 --code1=0 --code2=0 --p1

3. Similar to the previous step, but instead focusing more on the second

continuous code. Figure 6.1.7 shows that the second continuous code

controls the rotation angle (tilt) of the writing style:

[ 177 ]

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

Saved successfully!

Ooh no, something went wrong!