do I use "rescale=1. / 255" or not? Building VGG-like CNN

2.7k views Asked by At

I am building a CNN with a similar architecture as VGG16. I know in VGG16 u do rescale u also center around 0. Now I train mine from scratch, does it make a difference and should I do it or no? Anyone who can help?

datagen = ImageDataGenerator(rescale=1. / 255)

Thanks a lot guys! <3

2

There are 2 answers

1
Dimitris Chasanidis On BEST ANSWER

Rescaling to 0-1 in general is always a good choice when training neural networks, so yes go for it. The reason behind this is that neural networks tend to yield better results when the inputs are normalised. You could run the same exact experiment with pixel rescaling and without pixel rescaling and see for yourself the results!

0
Gerry P On

It is best to rescale your pixel values so that the mean is 0 and the values range from 1 to -1. Most of the pretrained model require that you do that. You can use tf.keras.applications.imagenet_utils.preprocess_input to achieve that. Documentation is here.