3
def preprocess_input(x):
x /= 255.
x -= 0.5
x *= 2.
return x

 I am using keras inception_v3 imagenet pretrained model(inception_v3.py) to finetune on my own dataset.
 When I want to subtract the imagenet mean value [123.68, 116.779, 103.939] and reverse axis RGB to BGR as we often do, I find that the author provided a _preprocess_input()_ function at the end.I am confused about this.

  Should I use the provided function preprocess_input() or subtract mean value and reverse axis as usual?
  Thanks lot.

Marcin Możejko
  • 39,542
  • 10
  • 109
  • 120
xiaoming-qxm
  • 1,738
  • 14
  • 23

1 Answers1

3

Actually in a original Inception paper the autors mention as a data preprocessor the function you provided (one which is zero-centering all channels and resizes it to [-1, 1] interval). As in InceptionV3 paper no new data transformation is provided I think that you may assume that you should use the following function:

def preprocess_input(x):
    x /= 255.
    x -= 0.5
    x *= 2.
    return x
Marcin Możejko
  • 39,542
  • 10
  • 109
  • 120
  • I have read Inception paper "Going Deeper with Convolutions", but I didn't see such preprocessor function, can you give me more details? – xiaoming-qxm Feb 17 '17 at 07:07
  • 1
    Actually - it's not mentioned directly. But it's written in a part where they mentioned about zero-centered RGB channels. Squashing your input to [-1, 1] is an often transformation in this case. – Marcin Możejko Feb 17 '17 at 08:12