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

why not zero mean the input #28

Open
youkaichao opened this issue Oct 24, 2017 · 1 comment
Open

why not zero mean the input #28

youkaichao opened this issue Oct 24, 2017 · 1 comment

Comments

@youkaichao
Copy link

the input of Inception is zero meaned(see part 5in the paper ).
but the code has a condition

assert(np.max(images[0]) > 10)
assert(np.min(images[0]) >= 0.0)

can you explain the difference?
Thanks!

@lzhbrian
Copy link

lzhbrian commented Apr 7, 2019

I am investigating inception score recently, after checking the network used: http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz

I found that the network has already handled

  • resize (arbitrary HxW to 299x299)
  • normalization (0~255 to -1~1)

Although this is an old issue, I found nothing about the details of this IS implementation all over the internet.
So mark it here, and hope this could save others' time.

import tensorflow as tf
import os
with tf.gfile.FastGFile('classify_image_graph_def.pb', 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    _ = tf.import_graph_def(graph_def, name='')
sess = tf.Session()

resize_bilinear = sess.graph.get_tensor_by_name('ResizeBilinear:0')
sess.run(resize_bilinear, {'ExpandDims:0': np.ones((1, H, W, 3))}).shape
# output is (1, 299, 299, 3)

Sub = sess.graph.get_tensor_by_name('Sub:0')
sess.run(Sub, {'ExpandDims:0': 255 * np.zeros((1,299,299,3))})
# output is all -128

Mul = sess.graph.get_tensor_by_name('Mul:0')
sess.run(Mul, {'ExpandDims:0': 255 * np.zeros((1,299,299,3))})
# output is all -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

2 participants