To generate images, we need a noise vector, sampled from latent space. Numpy has a method called uniform() that generates a vector from a uniform distribution. Let's see how to generate images in the following steps:
- Create a noise vector of a dimension of (batch_size, 100) by adding the following line of code:
z_noise = np.random.normal(0, 1, size=(batch_size, z_shape))
- Then, use the generator model's predict_on_batch method to generate an image. Feed it with the noise vector created in the previous step:
gen_images = gen_model.predict_on_batch(z_noise)
- Now that we have generated the image, save it by adding the following line of code. Create a directory called results to store the generated images:
imsave('results/image_{}.jpg'.format(epoch),gen_images[0])
You can now open these generated images to measure the quality of the generated model. This is a passive method to estimate the performance of the model.