title: Tensorflow / Keras mean image subtraction
body: <p>During training data generation a mean image <em>(not mean pixel values per channel)</em> is calculated. </p>
  
  <p>In order to improve the learning process, I would like to apply a simplified method to zero-center and normalize my network input data, which mainly consists of RGB images:</p>
  
  <pre><code>image = (image - meanImage + 1.0) / 2.0
  </code></pre>
  
  <p>As DL Framework, I'm using Keras - to load the training data tfrecords files like described <a href="https://medium.com/@moritzkrger/speeding-up-keras-with-tfrecord-datasets-5464f9836c36" rel="nofollow noreferrer">here</a> are used.</p>
  
  <p>At some point of my loading pipeline, I've the input (X) and output (Y) tensors:</p>
  
  <pre><code>def datasetLoader(dataSetPath, batchSize):
     dataset = tf.data.TFRecordDataset(dataSetPath)
  
     dataset = dataset.map(_ds_parser, num_parallel_calls=8)
  
     # This dataset will go on forever
     dataset = dataset.repeat()
  
     # Set the batchsize
     dataset = dataset.batch(batchSize)
  
     # Create an iterator
     iterator = dataset.make_one_shot_iterator()
  
     # Create your tf representation of the iterator
     X, Y = iterator.get_next()  
  
     # Bring the date back in shape
     X = tf.reshape(I, [-1, 66, 198, 3])
     Y = tf.reshape(Y,[-1,1])
  
     return X, Y
  </code></pre>
  
  <p>The variables X and Y are just tensors which get populated during a tensorflow session later on. </p>
  
  <p><strong>The question is:</strong> How can I use my local png mean image to perform the zero-center and normalize task? .</p>