0

I'm using Keras on Python to train a CNN autoencoder. In the fit() method I have to provide validation_split or validation_data. First, I would like to use 80% of my data as training data and 20% as validation data (random split). As soon as I have found the best parameters, I would like to train the autoencoder on all the data, i.e. no more using a validation set.

Is it possible to train a Keras model without using a validation set, i.e. using all data to train?

Moreover, the pixels in my images are all in the range [0, -0.04]. Is it still recommended to normalize the values of all pixels in all images in the training and validation set to the range [0,1] or to [-1,1] or to standardize it (zero mean, unit variance)? If so, which method is prefered? By the way, my images are actually 2D heat maps (one color channel).

machinery
  • 5,972
  • 12
  • 67
  • 118

1 Answers1

2

Yes, you can train a keras model without validation data, but its not a good practice, because then you would not know if the model can generalize or not. The same applies for autoencoders, they can overfit to the training set.

It is always recommended to normalize your inputs, specially if the ranges are large or small. There is no preferred method, any normalization generally works the same.

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140
  • Thank you. Would you normalize by pixel or by image (i.e. normalizing each pixel over all images or normalizing each image separately)? Let's say I have an numpy array of size (60000, 56, 89, 1), i.e. 60'000 images and each image of size 56 x 89 (1 color channel). How can I normalize this array using zero mean and unit variance (per pixel or per image)? – machinery Jul 17 '19 at 13:40
  • @machinery substract np.mean(array, axis=0) and divide by np.std(array, axis=0) – Dr. Snoopy Jul 17 '19 at 14:19
  • I think this will do sample wise standardization (i.e. standardize each image separately). How can I do pixelwise standardization (i.e. subracting mean image)? Is samplewise or pixelwise better? – machinery Jul 17 '19 at 14:25
  • @machinery No, you need to apply the operations I mentioned to the whole training set, due to broadcasting it will do pixelwise normalization. No normalization is better than other in general – Dr. Snoopy Jul 17 '19 at 15:39
  • Great, I will give it a try. As I have mentioned the pixel values are in range [0, -0.04], so when I divide by the standard deviation this will give me pretty huge values. For example, let's say the standard deviation is 0.00003 and the pixel value is -0.02, then -0.02 / 0.00003 = 666. Is this not a problem? I have seen that data is usually between 0 and 1 to avoid problems with calculating gradients. – machinery Jul 17 '19 at 16:03