caffe icon indicating copy to clipboard operation
caffe copied to clipboard

Stuck at getting mean file while visualizing filter weights/features

Open dasabir opened this issue 12 years ago • 1 comments

Hi All,

After training a net, I want to visualize the weights and features generated at different layers for a test image. I consulted 'Filter visualization' (http://nbviewer.ipython.org/github/BVLC/caffe/blob/master/examples/filter_visualization.ipynb) tutorial. I could run and see the weights and features of the example image by following the tutorial. Now, when I'm trying to do this for the network trained on my custom dataset, I'm stuck at the point when the python code needs the mean data in a npy format. Could you guys help me in generating the mean file in npy format? When I read the mean file in the tutorial (ilsvrc_2012_mean.npy), I saw that it's shape is (3,256,256). So I assume that if I take the mean of say 1000 images (each of dimension 32x32x3) I will get a npy file of size 32x32x3. Please let me know if generating such a mean file will be right for visualizing the weights. Is the order of channels (RGB or BGR) a concern (like some of the comments written in the demo Matlab code)?

Is there a way to confirm that the mean file generated in this way is the same as the .binaryproto file generated by the 'compute_image_mean' code (Used while training the network - Following the ImageNet tutorial - http://caffe.berkeleyvision.org/gathered/examples/imagenet.html)?

Many thanks, Abir

dasabir avatar Aug 01 '14 05:08 dasabir

Duplicate; see #808. Note that the mean is stored in Caffe in order of channel x height x width but in MATLAB this turns into width x height x channel since it is column major while Caffe is row major. You do need to match the channel order of your mean to the channel order of your data.

shelhamer avatar Aug 06 '14 00:08 shelhamer