generating images with variational autoencoders once such model is trained--on mnistin this case--you can use the decoder network to turn arbitrary latent space vectors into images listing sampling grid of points from the latent space and decoding them to images import matplotlib pyplot as plt from scipy stats import norm you'll display grid of digits ( digits totaln transforms linearly spaced digit_size coordinates using the scipy ppf figure np zeros((digit_size ndigit_size )function to produce values of the grid_x norm ppf(np linspace( )latent variable (because the prior grid_y norm ppf(np linspace( )of the latent space is gaussianfor iyi in enumerate(grid_x)repeats multiple times to for jxi in enumerate(grid_y)form complete batch z_sample np array([[xiyi]]z_sample np tile(z_samplebatch_sizereshape(batch_size x_decoded decoder predict(z_samplebatch_size=batch_sizedigit x_decoded[ reshape(digit_sizedigit_sizefigure[ digit_size( digit_sizej digit_size( digit_sizedigit plt figure(figsize=( )plt imshow(figurecmap='greys_r'plt show(reshapes the first digit in the batch from to decodes the batch into digit images the grid of sampled digits (see figure shows completely continuous distribution of the different digit classeswith one digit morphing into another as you follow path through latent space specific directions in this space have meaningfor examplethere' direction for "four-ness,"one-ness,and so on in the next sectionwe'll cover in detail the other major tool for generating artificial imagesgenerative adversarial networks (gansfigure space licensed to grid of digit decoded from he latent