generative deep learning in technical termshere' how vae works an encoder module turns the input samples input_img into two parameters in latent space of representationsz_mean and z_log_variance you randomly sample point from the latent normal distribution that' assumed to generate the input imagevia z_mean exp(z_log_varianceepsilonwhere epsilon is random tensor of small values decoder module maps this point in the latent space back to the original input image because epsilon is randomthe process ensures that every point that' close to the latent location where you encoded input_img ( -meancan be decoded to something similar to input_imgthus forcing the latent space to be continuously meaningful any two close points in the latent space will decode to highly similar images continuitycombined with the low dimensionality of the latent spaceforces every direction in the latent space to encode meaningful axis of variation of the datamaking the latent space very structured and thus highly suitable to manipulation via concept vectors the parameters of vae are trained via two loss functionsa reconstruction loss that forces the decoded samples to match the initial inputsand regularization loss that helps learn well-formed latent spaces and reduce overfitting to the training data let' quickly go over keras implementation of vae schematicallyit looks like thisz_meanz_log_variance encoder(input_imgencodes the input into mean and variance parameter z_mean exp(z_log_varianceepsilon decodes back to an image draws latent point using small random epsilon reconstructed_img decoder(zmodel model(input_imgreconstructed_imginstantiates the autoencoder modelwhich maps an input image to its reconstruction you can then train the model using the reconstruction loss and the regularization loss the following listing shows the encoder network you'll usemapping images to the parameters of probability distribution over the latent space it' simple convnet that maps the input image to two vectorsz_mean and z_log_var listing vae encoder net work import keras from keras import layers from keras import backend as from keras models import model import numpy as np img_shape ( batch_size latent_dim dimensionality of the latent spacea plane input_img keras input(shape=img_shapelicensed to