Extracting features with Matlab script "matcaffe_demo.m"
Hi,
I'm planning to use a pretrained ilsvrc12 model as a feature extractor for a new image dataset, and train svm classifiers for the new set. Is this sensible at all?
The "layers" output of the Matlab script "matcaffe_demo.m" has the following fields for the 8 layers, which of them should I use for my purpose? Many thanks.
[ 4-D single]
[96x1 single]
[ 4-D single]
[256x1 single]
[ 4-D single]
[384x1 single]
[ 4-D single]
[384x1 single]
[ 4-D single]
[256x1 single]
[9216x4096 single]
[4096x1 single]
[4096x4096 single]
[4096x1 single]
[4096x1000 single]
[1000x1 single]
And the numbers in "layers" are the same for different images ("scores" are different for different images and they make sense), something is wrong?
The layers are the CNN's weights, not the extracted features. The features from the output layer in the prototxt can be retrieved using the 'forward' command.
On Wed, May 21, 2014 at 3:32 PM, caffecuda [email protected] wrote:
And the numbers in "layers" are the same for different images ("scores" are different for different images and they make sense), something is wrong?
— Reply to this email directly or view it on GitHubhttps://github.com/BVLC/caffe/issues/432#issuecomment-43823021 .
http://www.cs.berkeley.edu/~rbg/
Thanks for the reply. Is there any example Matlab script for extracting features at a specific layer? "scores = caffe('forward', input_data);" returns only output of the last layer ie the probabilities.
@rbgirshick In particular to extract features that are good for classification, in the imagenet_deploy.prototxt file should I keep layers up to "fc7", or "relu7", or "drop7"? Many thanks!
While extracting features, the net is in Test mode, and therefore drop7 don't do anything, so you can leave it for take it out. But you should definitely keep relu7, it would make the features more sparse. Although you could do it later in Matlab.
Sergio
2014-05-28 10:44 GMT-07:00 caffecuda [email protected]:
@rbgirshick https://github.com/rbgirshick In particular to extract features that are good for classification, in the imagenet_deploy.prototxt file should I keep layers up to "fc7", or "relu7", or "drop7"? Many thanks!
— Reply to this email directly or view it on GitHubhttps://github.com/BVLC/caffe/issues/432#issuecomment-44440860 .
@sguada Thanks for the explanation. When used as a feature extractor for new dataset, I noticed that keeping relu7 also helps the classification performance, is this always the case? Is relu7 the best feature (for classification), or lower layers can be better?
It depends on the task, in some cases, fc6 or even pool5 perform better. Take a look into http://arxiv.org/abs/1310.1531
I think keeping relu always help, since the network was trained in that way, and therefore the negative values are noisy.
Sergio
2014-05-28 12:42 GMT-07:00 caffecuda [email protected]:
@sguada https://github.com/sguada Thanks for the explanation. When used as a feature extractor for new dataset, I noticed that keeping relu7 also helps the classification performance, is this always the case? Is relu7 the best feature (for classification), or lower layers can be better?
— Reply to this email directly or view it on GitHubhttps://github.com/BVLC/caffe/issues/432#issuecomment-44454783 .
@sguada Thanks. And I suppose I can use the mean of the features for the 10 crops as the feature for an image?
I guess you could, although not sure how well it would work if you do mean of pool5 features to represent an image. You could just use the central crop if you want to save computation.
Sergio
2014-05-28 12:57 GMT-07:00 caffecuda [email protected]:
@sguada https://github.com/sguada Thanks. And I suppose I can use the mean of the features for the 10 crops as the feature for an image?
— Reply to this email directly or view it on GitHubhttps://github.com/BVLC/caffe/issues/432#issuecomment-44456447 .
@caffecuda take a look to the new MatCaffe #501