Advanced Deep Learning with Keras
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 ]
- Page 143 and 144: Improved GANsIn summary, the goal o
- Page 145 and 146: Improved GANsThe intuition behind E
- Page 147 and 148: Improved GANsThis makes sense since
- Page 149 and 150: Improved GANsIn the context of GANs
- Page 151 and 152: Improved GANsFigure 5.1.3: Top: Tra
- Page 153 and 154: Improved GANsThe functions include:
- Page 155 and 156: Improved GANsmodels = (generator, d
- Page 157 and 158: Improved GANsfor layer in discrimin
- Page 159 and 160: Improved GANsFollowing figure shows
- Page 161 and 162: Improved GANsThe preceding table sh
- Page 163 and 164: Improved GANsFollowing figure shows
- Page 165 and 166: Improved GANsEssentially, in CGAN w
- Page 167 and 168: Improved GANslayer = Dense(layer_fi
- Page 169 and 170: Improved GANsx = BatchNormalization
- Page 171 and 172: Improved GANsdiscriminator.compile(
- Page 173 and 174: Improved GANssize=batch_size)real_i
- Page 175 and 176: Improved GANsUnlike CGAN, the sampl
- Page 177 and 178: Improved GANsConclusionIn this chap
- Page 179 and 180: Disentangled Representation GANsIn
- Page 181 and 182: Disentangled Representation GANsInf
- Page 183 and 184: Disentangled Representation GANsFol
- Page 185 and 186: Disentangled Representation GANs# A
- Page 187 and 188: Disentangled Representation GANsif
- Page 189 and 190: Disentangled Representation GANsLis
- Page 191 and 192: Disentangled Representation GANsdat
- Page 193: Disentangled Representation GANsy[b
- Page 197 and 198: Disentangled Representation GANsThe
- Page 199 and 200: Disentangled Representation GANsSta
- Page 201 and 202: Disentangled Representation GANs( )
- Page 203 and 204: Disentangled Representation GANsThe
- Page 205 and 206: Disentangled Representation GANsfea
- Page 207 and 208: Disentangled Representation GANs# f
- Page 209 and 210: Disentangled Representation GANslat
- Page 211 and 212: Disentangled Representation GANsDis
- Page 213 and 214: Disentangled Representation GANsz_d
- Page 215 and 216: Disentangled Representation GANs2.
- Page 217 and 218: Disentangled Representation GANsFig
- Page 220 and 221: Cross-Domain GANsIn computer vision
- Page 222 and 223: Chapter 7There are many more exampl
- Page 224 and 225: The CycleGAN ModelFigure 7.1.3 show
- Page 226 and 227: Chapter 7Repeat for n training step
- Page 228 and 229: Chapter 7Implementing CycleGAN usin
- Page 230 and 231: filters=16,kernel_size=3,strides=2,
- Page 232 and 233: Chapter 7kernel_size=kernel_size)e3
- Page 234 and 235: Listing 7.1.3, cyclegan-7.1.1.py sh
- Page 236 and 237: Chapter 71) Build target and source
- Page 238 and 239: Chapter 7preal_target,reco_source,r
- Page 240 and 241: size=batch_size)real_source = sourc
- Page 242 and 243: Chapter 7returndirs=dirs,show=True)
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 ]