如何在 c++ 中获取图层的顶部标签?

How can I get layer's top label in c++?

本文关键字:顶部 标签 图层 获取 c++      更新时间:2023-10-16

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) 我在哪里可以找到教程或示例,这些教程或示例解释了使用 caffe 框架使用 caffe 框架的最常用 API?

提前谢谢你。

看看 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_界面访问各种名称/数据,只需阅读文档即可!