Search code examples
python-3.xtensorflowneural-networkgenerative-adversarial-network

Should the random noise given to a GAN kept constant?


I am working on a Generative Adversarial Network ( GAN ). At every step, in the training, I call a method generate_noise which returns a tensor of some random noise.

# Generates noise of normal distribution
def generate_noise( shape : tuple ):
    noise = tf.random_normal( shape )
    return noise

When I call this method, I receive a random noise tensor which is given to the generator network. My question is :

If the generator receives random inputs everytime ( at every step ) , how can it optimise itself to create a meaningful image ( output )?

Then should I make the noise at every step constant. Meaning, only one noise tensor is passed at every step.

# Generates noise of normal distribution
noise = tf.random_normal( shape )
def generate_noise( ):
    return noise

Should I make the noise constant so that the generator network has to deal with one input and hence it can create a meaningful output?

Referring to many videos and blogs on GAN. I could not find whether the noise is kept constant or not. Any help is appreciated.


Solution

  • No, the noise should not be constant during training. For a given latent noise vector a GAN can generate only a single image. If you keep the noise constant, the GAN can only produce one image.

    The only case where you would want the noise to be constant would be if you wanted to visualize how the GAN progresses during training for a single instance.

    For example the following image is produced this way. Note that at each spot the same image is generated. This is done by passing the same input noise vector to the GAN at different stages during its training.