Kevin - 4 months ago 141

Python Question

On http://cs231n.github.io/neural-networks-2/ it is mentioned that for convolutional neural networks it is preferred to preprocess data using mean subtraction and normalization techniques.

I was just wondering how would it be best approached using Tensorflow.

Mean substraction

`X -= np.mean(X)`

Normalization

`X /= np.std(X, axis = 0)`

Answer

You're looking for `tf.image.per_image_whitening(image)`

:

Linearly scales image to have zero mean and unit norm.

This op computes (x - mean) / adjusted_stddev, where mean is the average of all values in image, and adjusted_stddev = max(stddev, 1.0/sqrt(image.NumElements())).