Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

choice of mean values in mean_subtract() function #10

Open
akshay-vaidya opened this issue Dec 12, 2017 · 2 comments
Open

choice of mean values in mean_subtract() function #10

akshay-vaidya opened this issue Dec 12, 2017 · 2 comments

Comments

@akshay-vaidya
Copy link

How was the mean values of BGR decided?
In the mean_subtract() function, how are the values 123.68, 116.779 and 103.939 decided?
def mean_subtract(img):
img = T.set_subtensor(img[:,0,:,:],img[:,0,:,:] - 123.68)
img = T.set_subtensor(img[:,1,:,:],img[:,1,:,:] - 116.779)
img = T.set_subtensor(img[:,2,:,:],img[:,2,:,:] - 103.939)

return img / 255.0

And how do I customize it?

@duggalrahul
Copy link
Owner

Those are the channel-wise mean of images in the ImageNet dataset on which the model was pre-trained. This is done to keep the channel-wise mean (per batch) close to zero, which itself is known to speed up training [1].

I believe subtracting this mean, become less of a factor when the pixel intensities are scaled from [0,255] to [0,1]. So either you could compute channel-wise mean of images on your training set or otherwise not subtract any mean and divide by 255.

You could setup a simple experiment to confirm (or discard) this hypothesis. Would love to hear back on your results!

[1] Clevert, Djork-Arné, Thomas Unterthiner, and Sepp Hochreiter. "Fast and accurate deep network learning by exponential linear units (elus)." arXiv preprint arXiv:1511.07289 (2015).

@akshay-vaidya
Copy link
Author

akshay-vaidya commented Dec 12, 2017

@duggalrahul Thanks much for your response. I will experiment on the hypothesis you have mentioned and will update you on the results. But do you think it is still valid to use subtract channel-wise mean of images of the ImageNet dataset when I am actually not using the pretrained weights and I am training the network from scratch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants