dataset mean and scale

92 views
Skip to first unread message

Amin

unread,
Apr 10, 2018, 8:09:10 AM4/10/18
to Caffe Users
Hello
I am using MobileNet-SSD and I have trained a model with my own dataset.
I used the mobilenet_iter_73000.caffemodel (available for download from the page) for finetuning from it.

The trained model is working and it's not bad.

But for better result should I calculate mean value and scale of my dataset and use them when tarining and test? or default values of MobileNet_SSD is good?

Default values in MobileNetSSD_train.prototxt:
scale: 0.007843
mean_value: 127.5
mean_value: 127.5
mean_value: 127.5

My dataset images are and 24 bit .bmp and grayscale and I use lmdb.

How about when I am using my previous snapshot for finetuning?

If it is important to change them, how can I calculate them and which part of code should change?

Thanks

Przemek D

unread,
Apr 11, 2018, 10:29:25 AM4/11/18
to Caffe Users
The idea behind mean subtraction is to remove the biases in individual pixel dimensions. It's also called zero-centering because it bring the data samples closer to zero in the pixel space. The reason is, if some of the pixels have little variance (e.g. you always have the same red spot on all images) they carry little information, so they should be removed (zeroed). Now, if you fine-tune a model however, you introduce a new dataset with its own bias - different from the source dataset - which should be eliminated as well.

For a simple example, the ImageNet mean is mostly blue, due to large number of the images showing either sky or bodies of water etc., and subtracting that mean for the ImageNet task removes the bias from those objects. Now suppose you transfer a model pre-trained on ImageNet onto some new dataset - for example plants. This dataset might introduce its own bias which should be removed - a lot of green everywhere. After subtracting the ImageNet mean you're still left with some of the green, and also most of the blue channel negated. Subtraction of your target dataset's mean is the right course of action, because it eliminates the green stuff, the actually important bias.

Probably someone who wields theory better than me would explain it more correctly - please consider this as an advice from a practitioner: I've been doing this and it works well ;-)
Reply all
Reply to author
Forward
0 new messages