caffe源码阅读遇到的问题

来源:互联网 发布:淘宝图片保护怎么破解 编辑:程序博客网 时间:2024/05/19 21:16
#include<vector>#include<iostream>#include<caffe\net.hpp>#include"head.h"using namespace std;using namespace caffe;int main(){string proto("deploy.prototxt");Net<float> nn(proto, caffe::TEST);vector<string> bn = nn.blob_names();for (int i = 0; i < bn.size(); i++){cout <<"Blob #"<<i<<":"<<bn[i] << endl;}return 0;}

为了了解Net在caffe的运用,我们编写了上述代码,运行过程中发现出现(deploy.prototxt在E:\Caffe\caffe-windows\models\bvlc_reference_caffenet中)

F0519 14:54:12.494139 14504 layer_factory.hpp:77] Check failed: registry.count(t ype) == 1 (0 vs. 1) Unknown layer type: Input (known types: Input )

解决方案:http://blog.csdn.net/zhoushiwei2010/article/details/77400914

于是我新建了一个头文件

#ifndef _HEAD_H_#define _HEAD_H_#include "caffe/common.hpp"  #include "caffe/layers/input_layer.hpp"  #include "caffe/layers/inner_product_layer.hpp"  #include "caffe/layers/dropout_layer.hpp"   namespace caffe{extern INSTANTIATE_CLASS(InputLayer);extern INSTANTIATE_CLASS(InnerProductLayer);extern INSTANTIATE_CLASS(DropoutLayer);}#endif
通过添加extern INSTANTIATE_CLASS(*******)来添加层并注册,在自己搭建框架是横重要

原创粉丝点击