MCPcopy Create free account
hub / github.com/BVLC/caffe / LayerSetUp

Method LayerSetUp

src/caffe/layers/log_layer.cpp:9–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8template <typename Dtype>
9void LogLayer<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_.log_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 base_scale_ = Dtype(1) / log_base;
24 CHECK(!isnan(base_scale_))
25 << "NaN result: 1/log(base) = 1/log(" << base << ") = " << base_scale_;
26 CHECK(!isinf(base_scale_))
27 << "Inf result: 1/log(base) = 1/log(" << base << ") = " << base_scale_;
28 input_scale_ = this->layer_param_.log_param().scale();
29 input_shift_ = this->layer_param_.log_param().shift();
30 backward_num_scale_ = input_scale_ / log_base;
31}
32
33template <typename Dtype>
34void LogLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected