如何在Caffe中计算绝对Dtype值?

问题描述 投票:0回答:1

我正在努力在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
...
Dtype myval = fabs(A+B+prob_data[idx]); // which abs function to be used here?? 

非常感谢您的帮助。

c++ caffe
1个回答
2
投票

在查看了caffe代码后,我找到了解决方案的答案。我可以干脆做

Dtype myval = Dtype( std::abs(A+B+prob_data[idx]) );
© www.soinside.com 2019 - 2024. All rights reserved.