MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / LayerSetUp

Method LayerSetUp

rtpose_wrapper/src/caffe/layers/prelu_layer.cpp:12–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11template <typename Dtype>
12void PReLULayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
13 const vector<Blob<Dtype>*>& top) {
14 CHECK_GE(bottom[0]->num_axes(), 2)
15 << "Number of axes of bottom blob must be >=2.";
16 PReLUParameter prelu_param = this->layer_param().prelu_param();
17 int channels = bottom[0]->channels();
18 channel_shared_ = prelu_param.channel_shared();
19 if (this->blobs_.size() > 0) {
20 LOG(INFO) << "Skipping parameter initialization";
21 } else {
22 this->blobs_.resize(1);
23 if (channel_shared_) {
24 this->blobs_[0].reset(new Blob<Dtype>(vector<int>(0)));
25 } else {
26 this->blobs_[0].reset(new Blob<Dtype>(vector<int>(1, channels)));
27 }
28 shared_ptr<Filler<Dtype> > filler;
29 if (prelu_param.has_filler()) {
30 filler.reset(GetFiller<Dtype>(prelu_param.filler()));
31 } else {
32 FillerParameter filler_param;
33 filler_param.set_type("constant");
34 filler_param.set_value(0.25);
35 filler.reset(GetFiller<Dtype>(filler_param));
36 }
37 filler->Fill(this->blobs_[0].get());
38 }
39 if (channel_shared_) {
40 CHECK_EQ(this->blobs_[0]->count(), 1)
41 << "Negative slope size is inconsistent with prototxt config";
42 } else {
43 CHECK_EQ(this->blobs_[0]->count(), channels)
44 << "Negative slope size is inconsistent with prototxt config";
45 }
46
47 // Propagate gradients to the parameters (as directed by backward pass).
48 this->param_propagate_down_.resize(this->blobs_.size(), true);
49 multiplier_.Reshape(vector<int>(1, bottom[0]->count(1)));
50 backward_buff_.Reshape(vector<int>(1, bottom[0]->count(1)));
51 caffe_set(multiplier_.count(), Dtype(1), multiplier_.mutable_cpu_data());
52}
53
54template <typename Dtype>
55void PReLULayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,

Callers

nothing calls this directly

Calls 11

caffe_setFunction · 0.85
num_axesMethod · 0.80
countMethod · 0.80
channelsMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
resetMethod · 0.45
FillMethod · 0.45
getMethod · 0.45
ReshapeMethod · 0.45
mutable_cpu_dataMethod · 0.45

Tested by

no test coverage detected