title: Keras normalization pollutes data
body: <p>I've written simple digit recognition model that was fed with images from MNIST and I wanted to use this model to predict my own digits but I bumped into problems with normalization. </p>
  
  <p>To normalize images from MNIST I used:</p>
  
  <pre><code>x_train = keras.utils.normalize(x_train, axis=1)
  x_test = keras.utils.normalize(x_test, axis=1) # shape = (60000, 28, 28)
  </code></pre>
  
  <p>but when I'm trying to do the same with my own image:</p>
  
  <pre><code>my_digit = cv2.imread("three.jpg") # shape = (28, 28, 3)
  my_digit = cv2.cvtColor(my_digit, cv2.COLOR_RGB2GRAY) # shape = (28, 28)
  my_digits = np.array([my_digit]) # shape = (1, 28, 28)
  my_digits = keras.utils.normalize(my_digits, axis=1)
  </code></pre>
  
  <p>after normalization using keras image is getting a bit dirty:
  <a href="https://i.stack.imgur.com/F9zgP.png" rel="nofollow noreferrer">image with keras' normalization</a></p>
  
  <p>when I remove :</p>
  
  <pre><code>my_digits = keras.utils.normalize(my_digits, axis=1)
  </code></pre>
  
  <p>then image is fine <a href="https://i.stack.imgur.com/Ck7JB.png" rel="nofollow noreferrer">image without keras' normalization</a></p>
  
  <p>The 'solution' I found is dividing every element by 255 like that:</p>
  
  <pre><code>my_digit = np.divide(my_digit, 255)
  </code></pre>
  
  <p>then the image looks fine - like before normalization</p>
  
  <p>EDIT:
  Before normalization x_train(MNIST dataset) its dtype is uint8, after normalization it is float64. For my image - before normalization(utils.keras) its dtype is uint8 and after normalization it is float64. It is also the same when I normalize my digit by diving every item by 255 - I mean uint8 before and float64 after. </p>
  
  <p>I'm wondering why if I normalize my own images(images from MNIST after keras.utils.normalization looks as good as before normalization) manually then they look ok but when I use keras.utils.normalization then I'm getting some 'pollutions'</p>