improved-gan icon indicating copy to clipboard operation
improved-gan copied to clipboard

why not zero mean the input

Open youkaichao opened this issue 6 years ago • 1 comments

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!

youkaichao avatar Oct 24 '17 09:10 youkaichao

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

lzhbrian avatar Apr 07 '19 09:04 lzhbrian