I am building an image classifier based off the VGG_face keras implementation. It is easiest for me to extract a csv file full of the representations and then try classifiers on those representations. When I got the representations, I first subtracted the mean of the entire dataset from each image. Then I realized... am I cheating, so to speak? In other words, since I included the test images when calculating the grand mean to be subtracted, does this now then overestimate my accuracy measurements?


1 Answer 1


There is a kind of bias that you are introducing, yes. You are basically extracting some statistics (i.e. the mean) from your hold-out set and using that to train, which makes your final claims of accuracy a little weaker (some people might say they are useless).

The general approach is to compute the mean of your training data, then you may subtract that from all of the data, including hold-out data.

You can do the mean subtraction, in general, using something like the ImageDataGenerator. The mean to be subtracted can be computed using all or some of the training data. That class also offers other augmentation functionalities, such as normalising the dataset too, adding rotations etc.

you mentioned you read features from a CSV file, so if you are not talking about images, as long as you can use e.g. NumPy, you can perform is manually on all data at the beginning.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.