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

127.5 #12

Open
wxy656 opened this issue Mar 27, 2017 · 3 comments
Open

127.5 #12

wxy656 opened this issue Mar 27, 2017 · 3 comments

Comments

@wxy656
Copy link

wxy656 commented Mar 27, 2017

hi,what's the use of 127.5 in this code:
X_train = (X_train.astype(np.float32) - 127.5)/127.5

to scale the input datas? If yes ,than how do you calculate 127.5 , is it just match minist data?

@lixiang-ucas
Copy link

127.5 is half of 255, but why?

@liamnaka
Copy link

@lixiang-ucas The purpose of doing so is to normalize and scale the pixel data. You can read more about it here.

@ElectronicChaos
Copy link

The activation function of the output layer of the generator is tanh, which returns a value between -1 and 1. To scale that to 0 and 255 (which are the values you expect for an image), we have to multiply it by 127.5 (so that -1 becomes -127.5, and 1 becomes 127.5), and then add 127.5 (so that -127.5 becomes 0, and 127.5 becomes 255). We then have to do the inverse of this when feeding an image into the discriminator (which will expect a value between -1 and 1).

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

4 participants