-
Notifications
You must be signed in to change notification settings - Fork 204
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
Feature extraction #13
Comments
Hi, Try something like that: //Feature extraction
const shared_ptr<Blob<float> >& features = caffe_net->blob_by_name("fc7");
LOG(INFO) << "Features size " << features->count();
vector myfeatures = vector<float>(features->cpu_data(),features->cpu_data()+features->count()); Change "fc7" to whatever layer you want |
I'm also trying to extract features. I need the features before they are passed through the softmax layer, just like in the code snippet above. Where should I add this code? Is it caffe_mobile.cpp? |
Yes, you can simply add it to predict_top_k function or create a dedicated feature extraction function |
You can always modify the prototxt to extract features that are of interest to you. I have been able to extract features from the output of average pooling layer of a GoogLeNet model by simply removing the last three layers from the deploy prototxt file of the same model. You just re-run Forward() as before. |
Thanks for your responses. I wasn't familiar with the Java Native Interface. I was able to run it by modifying caffe_jni.cpp and caffe_mobile.cpp files. |
isikdogan, can you please share how you modified the caffe_jni.cpp and caffe_mobile.cpp files to be able to extract features from a layer in the network? |
Keyurpatel93, I just noticed your message. I no longer work on that project. The development version of OpenCV seems to have caffe-compatible functions. I don't know if those functions are available in the Android version yet, but if so then it could be more convenient to use them: |
Thanks to the discussions above. Feature extraction is integrated in the latest master branch, so I'm gonna close this issue. |
Thanks for the library. Is it possible extract features from different layers in the network?
The text was updated successfully, but these errors were encountered: