Random noise for GAN
Asked Answered
E

5

7

I am new to GAN. I am learning to model GAN to generate images,however I don't really understand what exactly is the random noise given to the generator. Is it random numbers from 0 to 1 and what should be its size. Also should the random noise be constant every time the generator run?

Any help would be appreciated.

Eskilstuna answered 5/3, 2020 at 20:54 Comment(0)
D
7

Random noise is a feature vector, unique for every image

Let's consider noise vector of 128

For now just focus on 1st entry from vector let's consider it is for length of hairs on head

From training images model has learnt that for bald the value is=0 and for long hair value=1, by selecting random number from 0 to 1 decides amount of hairs. so model can generate persons of different hair length

In this way all 128 entries in random noise will decide one factor of human face

That's why every time choosing random noise will generate new person image

If you use random noise same every then model will generate same image

I hope you understood how GAN works.

Dismiss answered 5/3, 2020 at 21:33 Comment(6)
So does the first random noise we give to the generator is based on the image dataset we give to the discriminator?Eskilstuna
you mentioned "from training images model has learnt that for bald the value is=0 and for long hair value=1", the training images is the input we give to the discriminator? please correct me if I am wrong.Eskilstuna
yes you're right from training images these values will be trainedDismiss
I would highly doubt that the entries of the noise vector are specifically attributed to a specific pathology (length of hair) in the generated sample. Rather it is similar to DNA, the information is definitely stored in DNA but it is not so easy as to locate where. Proof me wrong.Crucifer
obviously it is not easy to locate i am just giving an example if the 1st node is for the hair length then.........Dismiss
Oh okay then I missed out on the part where it said that your answer is hypothetical. Since it makes the impression that actually the random vector stores specific pathological information in each entry, following your example.Crucifer
C
2

The random noise vector distribution represents the latent space. It is not that important for GANs but more so for Autoencoders. Typically, the noise is generated from the normal distribution but some researchers have reported improved training results using a spherical distribution (sorry, I don't have the references handy). The range of the noise depend on your input layer. If you are using images, you probably normalized the inputs between 0 and 1 or -1 and 1, so you would use a corresponding distribution range for your noise vector. A typical noise vector might be generated like so:

noise = tf.random.normal([BATCH_SIZE, noise_dim])

where BATCH_SIZE is the size of the training batch (16, 32, 64, 128...) and noise_dim is the size of the noise vector, which depends on your feature space (I use 1024 often for medium resolution images).

Cardenas answered 27/3, 2020 at 3:44 Comment(0)
C
2

There is a jupyter notebook driven tutorial on github (full disclosure, it is my github). (Solutions available here)

The noise or rather latent random variable can be generated pretty much however you like for example such as follows:

# Generate latent random variable to feed to the generator, by drawing from a uniform distribution 
z = np.random.uniform(-1., 1., size=[batch_size, noise_dim])

Yet it makes sense to think about the activation function within the input layer of your generator, and pay attention to its sensitive range.

The generator takes this input as a seed to decode from that latent variable into the source datasets domain. So obviously the same random variable will lead to the exact same generated sample.

So you should constantly be drawing new samples while training, and do not keep the noise constant.

Crucifer answered 2/4, 2020 at 14:41 Comment(0)
W
0

I'm also new to GAN but working recently on GAN for signal generation.

Random noise is the input to the generator. At the beginning it has no meaning and with training you try to find meaning to them. Regarding the size i'm still not sure if my conclusion is correct so I hope the others correct my if I'm wrong. We should search for the suitable size for our Problems. If latent space is very small, the model will reach a point which it can't produce better quality anymore (bottleneck) and if it's too big, the model will take very Long time to produce good results and it may even fail to converge. Usually one starts with latent space size used by others for same Problem.

Wheaton answered 2/4, 2020 at 14:21 Comment(0)
P
0

The Random vector is not actually random, typically we sample the vector from some specific distribution (Gaussian , Uniform etc). The generator takes the sampled vector and then it tries to map it to the distribution of the training data by minimising the Jensen-Shannon Divergence of the probability distribution of the sampled vector and the distribution of the all the training data. The size of the sampled vector which we feed to the generator is a Hyperparameter.

Pentagram answered 1/3, 2021 at 16:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.