Finally, we can proceed to generate some novel handwritten digits with our VAE. To do this, we simply revisit the decoder part of our VAE (which naturally excludes the loss layer). We will be using it to decode samples from the latent space and generate some handwritten digits that were never actually written by anyone:
Next, we will display a grid of 15 x 15 digits, each of size 28. To do this, we initialize a matrix of zeros, matching the dimensions of the entire output to be generated. Then, we use the ppf function from SciPy to transform some linearly placed coordinates to get to the grid values of the latent variables (z). After this, we enumerate through these grids to obtain a sampled (z) value. We can now feed this sample to the generator network, which will decode the latent representation, to subsequently reshape the output...