How to do it...

There are two components within GANs – the generator and the discriminator. We start by creating individual generator and discriminator networks first, followed by chaining these two networks through a GAN model and training it. Let's get started:

  1. Since we are dealing with grayscale images, the number of channels will be 1. We also set the dimension of our random noise vector, which is used as input for the generator network, to 100:
channels <- 1set.seed(10)latent_dimension <- 100
  1. Next, we create the generator network. The generator network maps random normal noise vectors of shape latent_dimension to a vector of length equal to the flattened input image. The generator network consists of three hidden layers; the ...

Get Deep Learning with R Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.