There is a data blob of hdf5 [600000,1,7,256]
.The function 'compute_image_mean.cpp' in Caffe is not fit for HDF5. So how to do mean subtraction using Caffe in matlab?
Asked
Active
Viewed 62 times
3

Shai
- 111,146
- 38
- 238
- 371

Zhao Wulanaren
- 161
- 1
- 2
- 9
1 Answers
1
Suppose you have a matrix in MATLAB of 60K vectors, how would you subtract the mean in MATLAB?
X=bsxfun(@minus, X, mean(X, 1));
Now that you subtracted the mean you can save X to hdf5 and feed it to caffe.

Shai
- 111,146
- 38
- 238
- 371
-
Can I do it as the following way:there is a 3-D matrix X 7*256*600000.The mean of X is 2-D matrix.The mean matrix is named as Mean.Then Y(:,:,i)=X(:,:,i)-Mean where i=1:600000. – Zhao Wulanaren Apr 08 '16 at 05:35
-
@ZhaoWulanaren yes, but I suppose bsxfun is better – Shai Apr 08 '16 at 05:46
-
@ Shai Hi,does mean subtraction equal to normalization?That is,if I do mean subtraction ,there is no need to normalize the data. – Zhao Wulanaren Apr 08 '16 at 07:43
-
@ZhaoWulanaren there are all sorts of normalizations. some are done in the middle of the net and not only on the inputs – Shai Apr 08 '16 at 07:57
-
@ Shai Hello,I get some trouble.If I already have deploy.prototxt,solver.prototxt,train_val.prototxt.How can I code in matlab to call function of Caffe to train my data set.I know caffe-master\matlab\demo there is a demo code but it just for classsification not train.Is there a complete code about how to train one's own data set? – Zhao Wulanaren Apr 09 '16 at 06:47
-
@ZhaoWulanaren I am not familiar with the MATLAB interfave – Shai Apr 09 '16 at 17:01
-
@ Shai Hello,I did what you told me but I got another problem,do you know how to fix it? https://stackoverflow.com/questions/36601019/datatype-class-h5t-float-f0413-085440-661201-17769-hdf5-data-layer-cpp53-ch – Zhao Wulanaren Apr 13 '16 at 14:12
-
@ Shai Hello,I have some trouble.Can you give me some advice?http://stackoverflow.com/questions/42557209/how-to-use-caffe-to-extract-feature-of-non-images-data – Zhao Wulanaren Mar 02 '17 at 13:52