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

Method Forward_cpu

src/caffe/layers/prelu_layer.cpp:67–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66template <typename Dtype>
67void PReLULayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
68 const vector<Blob<Dtype>*>& top) {
69 const Dtype* bottom_data = bottom[0]->cpu_data();
70 Dtype* top_data = top[0]->mutable_cpu_data();
71 const int count = bottom[0]->count();
72 const int dim = bottom[0]->count(2);
73 const int channels = bottom[0]->channels();
74 const Dtype* slope_data = this->blobs_[0]->cpu_data();
75
76 // For in-place computation
77 if (bottom[0] == top[0]) {
78 caffe_copy(count, bottom_data, bottom_memory_.mutable_cpu_data());
79 }
80
81 // if channel_shared, channel index in the following computation becomes
82 // always zero.
83 const int div_factor = channel_shared_ ? channels : 1;
84 for (int i = 0; i < count; ++i) {
85 int c = (i / dim) % channels / div_factor;
86 top_data[i] = std::max(bottom_data[i], Dtype(0))
87 + slope_data[c] * std::min(bottom_data[i], Dtype(0));
88 }
89}
90
91template <typename Dtype>
92void PReLULayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,

Callers

nothing calls this directly

Calls 5

caffe_copyFunction · 0.85
countMethod · 0.80
cpu_dataMethod · 0.45
mutable_cpu_dataMethod · 0.45
channelsMethod · 0.45

Tested by

no test coverage detected