C++ 如何计算Caffe中的绝对数据类型值?
我正在Caffe中创建一个自定义图层。我需要为几个元素(而不是整个blob)计算Dtype的绝对值。我应该使用哪种绝对函数C++ 如何计算Caffe中的绝对数据类型值?,c++,caffe,C++,Caffe,我正在Caffe中创建一个自定义图层。我需要为几个元素(而不是整个blob)计算Dtype的绝对值。我应该使用哪种绝对函数 const Dtype* prob_data = bottom[0]->cpu_data(); const Dtype* label = bottom[1]->cpu_data(); ... const int idx = ... Dtype A = Dtype(-20); // example Dtype B = Dtype(10); // example
const Dtype* prob_data = bottom[0]->cpu_data();
const Dtype* label = bottom[1]->cpu_data();
...
const int idx = ...
Dtype A = Dtype(-20); // example
Dtype B = Dtype(10); // example
...
Dtype myval = fabs(A+B+prob_data[idx]); // which abs function to be used here??
非常感谢您的帮助。在查看caffe代码后,我找到了解决方案的答案。 我可以这么做
Dtype myval = Dtype( std::abs(A+B+prob_data[idx]) );
在查看caffe代码后,我找到了解决方案的答案。 我可以这么做
Dtype myval = Dtype( std::abs(A+B+prob_data[idx]) );