【问题标题】:How can I get layer's top label in c++?如何在 C++ 中获取图层的顶部标签?
【发布时间】:2018-04-08 19:12:18
【问题描述】:

1) 是否可以在 c++ 中获取每个层的顶部标签(例如:ip1、ip2、conv1、conv2)? 如果我的层是

layer {
  name: "relu1_1"
  type: "Input"
  top: "pool1"
  input_param { 
      shape: { 
          dim:1 
          dim: 1 
          dim: 28 
          dim: 28 
          } 
     }
}

我想获得顶部标签,在我的例子中是“pool1

我搜索了提供的示例,但找不到任何内容。目前我只能通过以下命令获取图层名称和图层类型,

cout << "Layer name:" << "'" << net_->layer_names()[layer_index]<<endl;
cout << "Layer type: " << net_->layers()[layer_index]->type()<<endl;

2) 我在哪里可以找到解释使用 c++ 使用 caffe 框架的最常用 API 的教程或示例?

提前谢谢你。

【问题讨论】:

    标签: c++ neural-network computer-vision deep-learning caffe


    【解决方案1】:

    查看 doxygen 中的Net 类:

    const vector< vector< Blob< Dtype > * > > all_ tops = net_->top_vecs();  // get "top" of all layers
    Blob<Dtype>* ptop = all_tops[layer_index][0];  // pointer to top blob of layer
    

    如果你想要图层的名字,你可以

    const string layer_name = net_->layer_names()[layer_index];
    

    您可以使用net_ 接口访问各种名称/数据,只需阅读doc

    【讨论】:

    • ptop 将给出指针,但我想访问顶级名称。例如,在我的情况下,我想获得“pool1”,但我无法从上面回答的指针中获得它。
    • @GaneshMS 请查看我的编辑,阅读docs
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-27
    • 2016-02-01
    • 2014-09-08
    • 2018-04-03
    • 2014-08-04
    相关资源
    最近更新 更多