16.03.2021 Views

Advanced Deep Learning with Keras

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

It is straightforward to implement β -VAE. For example, for the CVAE from the

previous, the required modification is the extra beta factor in kl_loss.

kl_loss = 1 + z_log_var - K.square(z_mean) - K.exp(z_log_var)

kl_loss = K.sum(kl_loss, axis=-1)

kl_loss *= -0.5 * beta

Chapter 8

CVAE is a special case of β -VAE with β = 1. Everything else is the same. However,

determining the value of β requires some trial and error. There must be a careful

balance between the reconstruction error and regularization for latent codes

independence. The disentanglement is maximized at around . When the

value of β > 8 , the β -VAE is forced to learn one disentangled representation only

while muting the other latent dimension:

Figure 8.3.1: The latent vector mean values for the test dataset ( β -VAE with 7 β = )

Color images can be found on the book GitHub repository: https://github.com/PacktPublishing/Advanced-

Deep-Learning-with-Keras/tree/master/chapter8-vae.

[ 265 ]

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

Saved successfully!

Ooh no, something went wrong!