Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about features = (features - 0.5)*2 in GAN model #56

Open
annyWangAn opened this issue Aug 5, 2021 · 3 comments
Open

question about features = (features - 0.5)*2 in GAN model #56

annyWangAn opened this issue Aug 5, 2021 · 3 comments

Comments

@annyWangAn
Copy link

Hi.
I have noticed the operation here ( features = (features - 0.5)*2) in Generative Adversarial Networks (GAN). I don't understand why we need to do this here. The mean and variance of MINIST dataset are 0.1307 and 0.3081. Can you please explain the meaning of doing so? Looking forward to your reply.

@rasbt
Copy link
Owner

rasbt commented Aug 5, 2021

Good question. Which notebook is that? My spontaneous thought is that I probably did that because PyTorch's data transformation normalizes pixels to [0, 1] range, and I wanted to have the images in [-1, 1] range.

@annyWangAn
Copy link
Author

https://github.com/rasbt/deeplearning-models/blob/master/pytorch_ipynb/gan/gan.ipynb
Why we need the images in [-1,1] range? What is the difference between the ranges of [0,1] and [-1,1]? Does the image range have a big influence on the net performance? Didn’t see a similar operation in the previous network. So why in this net we need to do so? Thank you again for your reply.

@rasbt
Copy link
Owner

rasbt commented Aug 11, 2021

Usually gradient descent behaves a bit better if the values are centered at 0. (Ideally, the mean should be zero). In practice, I don't notice big differences though to be honest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants