Reputation: 91
Here are three kinds of pre-processing methods to convert from uint8 to float32. Which one is recommended to be used in conv2d->batch norm->ReLU structure(e.g. robustness and avoiding dying ReLU problem), or any suggestion?
As mentioned in cs231n, zero-centered and normalized image using mean and std computed on training set. I think this method cost a lot when training set is huge.
Like the codes in tensorflow models,
image /= 255
image -= 0.5
image *= 2.0
Simply divide image by 255
Upvotes: 1
Views: 57
Reputation: 995
Preprocessing comes in different flavors, and it usually depends on the framework you use. For example, Pytorch normalizes to [0,1], Tensorflow normalizes to [-1,1] and Keras leaves the range as [0,255]. I referenced this from the Keras preprocessing code. In my experience, normalizing does not make any difference for images, so just stick with the one used in your framework. However, if you have other data, like time series of measurements, etc. normalization can make the difference to successful training.
Subtracting the mean and dividing by the std is fairly common and does not need to be computationally expensive due to broadcasting. This has been shown to make a difference in terms of accuracy. However, I usually only use it for datasets with large image sizes like ImageNet.
Upvotes: 2