【发布时间】:2017-04-17 17:28:25
【问题描述】:
如何在使用 C++ 进行一次前向传递后在 caffe 中同时获得 4096 dim 特征层和 1000 dim 类层?
我试图在 extract_features.cpp 中查找它,但它使用了一些奇怪的 datum 对象,所以我无法真正理解它是如何工作的。
到目前为止,我只是将我的 prototxt 文件裁剪到我想要提取和使用的层
[...]
net->ForwardPrefilled();
Blob<float> *output_layer = net->output_blobs()[0];
const float *begin = output_layer->cpu_data();
const float *end = begin + output_layer->channels();
return vector<float>(begin, end);
但如果我想同时提取两个特定层(例如“prob”和“fc7”),这将不起作用。
【问题讨论】:
-
你绝对需要使用 C++。在 python 中,从不同层提取特征要简单得多。
-
不幸的是,是的。 (在 python 上它已经在工作了。)
标签: machine-learning deep-learning caffe conv-neural-network