caffe编译问题error : class XXX has no member XXX

error : class "caffe::LossParameter" has no member "pre_fixed_normalizer"

这是要在caffe.proto中lossparameter添加pre_fixed_normalizer吗,要怎么添加?求赐教!

这个错误是因为caffe.proto文件中的LossParameter类中不存在pre_fixed_normalizer成员变量。如果你的代码中引用了这个成员变量,编译时就会报错。

要添加pre_fixed_normalizer成员变量,可以按照以下步骤进行:

1打开caffe.proto文件,一般位于/path/to/caffe/src/caffe/proto/caffe.proto。
2找到LossParameter类,一般在文件底部,类似如下代码:

message LossParameter {
  optional string type = 1 [default = "SOFTMAX_LOSS"];
  optional int32 axis = 2 [default = 1];
  optional float ignore_label = 3 [default = -1];
  optional bool normalize = 4 [default = true];
  repeated float coeff = 5;
  optional string normalization = 6 [default = "VALID"];
  optional float negative_weight = 7 [default = -1.0];
  optional float positive_weight = 8 [default = -1.0];
}


3在该类中添加一个新的成员变量pre_fixed_normalizer,例如:

message LossParameter {
  optional string type = 1 [default = "SOFTMAX_LOSS"];
  optional int32 axis = 2 [default = 1];
  optional float ignore_label = 3 [default = -1];
  optional bool normalize = 4 [default = true];
  repeated float coeff = 5;
  optional string normalization = 6 [default = "VALID"];
  optional float negative_weight = 7 [default = -1.0];
  optional float positive_weight = 8 [default = -1.0];
  optional float pre_fixed_normalizer = 9 [default = -1.0];
}


4保存文件,并重新编译caffe。