| 7 | |
| 8 | template <typename Dtype> |
| 9 | void ExpLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom, |
| 10 | const vector<Blob<Dtype>*>& top) { |
| 11 | NeuronLayer<Dtype>::LayerSetUp(bottom, top); |
| 12 | const Dtype base = this->layer_param_.exp_param().base(); |
| 13 | if (base != Dtype(-1)) { |
| 14 | CHECK_GT(base, 0) << "base must be strictly positive."; |
| 15 | } |
| 16 | // If base == -1, interpret the base as e and set log_base = 1 exactly. |
| 17 | // Otherwise, calculate its log explicitly. |
| 18 | const Dtype log_base = (base == Dtype(-1)) ? Dtype(1) : log(base); |
| 19 | CHECK(!isnan(log_base)) |
| 20 | << "NaN result: log(base) = log(" << base << ") = " << log_base; |
| 21 | CHECK(!isinf(log_base)) |
| 22 | << "Inf result: log(base) = log(" << base << ") = " << log_base; |
| 23 | const Dtype input_scale = this->layer_param_.exp_param().scale(); |
| 24 | const Dtype input_shift = this->layer_param_.exp_param().shift(); |
| 25 | inner_scale_ = log_base * input_scale; |
| 26 | outer_scale_ = (input_shift == Dtype(0)) ? Dtype(1) : |
| 27 | ( (base != Dtype(-1)) ? pow(base, input_shift) : exp(input_shift) ); |
| 28 | } |
| 29 | |
| 30 | template <typename Dtype> |
| 31 | void ExpLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom, |
nothing calls this directly
no outgoing calls
no test coverage detected