在caffe.proto中定义变量出现“'xxxParameter' has no member named 'xxx'”问题的解决

在caffe.proto中某一message添加成员变量时,最好避免使用大写字母。在编译过程中message里的成员变量名会自动将所有字母变为小写。如果在C++代码中仍然使用带有大写字母的变量时则会产生找不到定义的问题。

例如,在caffe.proto中的AccuracyParameter定义:

optional uint32 top_K = 1 [default = 1]; //K大写

且在C++代码中使用的是:

this->layer_param_.accuracy_param().top_K();  //K大写

则会出现’AccuracyParameter’ has no member named ‘top_K’的问题。而此时正确的方式则是应该使用:

this->layer_param_.accuracy_param().top_k();  //k小写

区别在于变量名的大小写问题上。