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

Method LayerSetUp

src/caffe/layers/bias_layer.cpp:10–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9template <typename Dtype>
10void BiasLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
11 const vector<Blob<Dtype>*>& top) {
12 if (bottom.size() == 1 && this->blobs_.size() > 0) {
13 LOG(INFO) << "Skipping parameter initialization";
14 } else if (bottom.size() == 1) {
15 // bias is a learned parameter; initialize it
16 const BiasParameter& param = this->layer_param_.bias_param();
17 const int axis = bottom[0]->CanonicalAxisIndex(param.axis());
18 const int num_axes = param.num_axes();
19 CHECK_GE(num_axes, -1) << "num_axes must be non-negative, "
20 << "or -1 to extend to the end of bottom[0]";
21 if (num_axes >= 0) {
22 CHECK_GE(bottom[0]->num_axes(), axis + num_axes)
23 << "bias blob's shape extends past bottom[0]'s shape when applied "
24 << "starting with bottom[0] axis = " << axis;
25 }
26 this->blobs_.resize(1);
27 const vector<int>::const_iterator& shape_start =
28 bottom[0]->shape().begin() + axis;
29 const vector<int>::const_iterator& shape_end =
30 (num_axes == -1) ? bottom[0]->shape().end() : (shape_start + num_axes);
31 vector<int> bias_shape(shape_start, shape_end);
32 this->blobs_[0].reset(new Blob<Dtype>(bias_shape));
33 shared_ptr<Filler<Dtype> > filler(GetFiller<Dtype>(param.filler()));
34 filler->Fill(this->blobs_[0].get());
35 }
36 this->param_propagate_down_.resize(this->blobs_.size(), true);
37}
38
39template <typename Dtype>
40void BiasLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,

Callers

nothing calls this directly

Calls 9

CanonicalAxisIndexMethod · 0.80
num_axesMethod · 0.80
shapeMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
resetMethod · 0.45
FillMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected