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

為何要對圖形中 0-255 的灰階像素值做 normalization (將灰階值數值範圍縮減到 [0 - 1])? #3

Open
renewang opened this issue Sep 28, 2018 · 1 comment
Labels
question Further information is requested

Comments

@renewang
Copy link
Collaborator

9/22 第二次讀書會(Chapter 2)現場提問

"A First Look at a Neural Network" note book 中,為何要將所有的灰階像素除以 255?(code example 如下)?

train_images = train_images.reshape((60000, 28 * 28))
train_images = train_images.astype('float32') / 255

test_images = test_images.reshape((10000, 28 * 28))
test_images = test_images.astype('float32') / 255
@renewang renewang added the question Further information is requested label Sep 28, 2018
@thouger
Copy link

thouger commented Oct 24, 2018

因为matplotlib的imshow函数,
image
根本imshow函数文档,当你的图片矩阵类型是unit8的时候,像素范围是0-255,但是你读取图片是以double类型的话,当大于1时就会被显示成白色,不能有效表达图片信息,这是因为imshow()显示图像时对double型是认为在0~1范围内。
The RGB(A) values should be in the range [0 .. 1] for floats or [0 .. 255] for integers.

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

No branches or pull requests

2 participants