File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ class PowLayer : public Layer<Dtype> {
2121 public:
2222 explicit PowLayer (const LayerParameter& param)
2323 : Layer<Dtype>(param) {}
24+ virtual void LayerSetUp (const vector<Blob<Dtype>*>& bottom,
25+ const vector<Blob<Dtype>*>& top);
2426 virtual void Reshape (const vector<Blob<Dtype>*>& bottom,
2527 const vector<Blob<Dtype>*>& top);
2628
Original file line number Diff line number Diff line change 66#include " caffe/layers/pow_layer.hpp"
77
88namespace caffe {
9+ template <typename Dtype>
10+ void PowLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
11+ const vector<Blob<Dtype>*>& top) {
12+ // Add the fake initialization to avoid special case in evconvert for the moment when
13+ // the prototxt is generated, the 2nd input is parameter to be fed into caffemodel, but the caffemodel is not generated yet
14+ if (bottom.size () == 1 && this ->blobs_ .size () == 0 )
15+ {
16+ LOG (WARNING) << " Note: Make fake parameter initialization to avoid segment fault!" ;
17+ // initialize the 2nd input to avoid error in reshape stage
18+ this ->blobs_ .resize (1 );
19+ const vector<int >::const_iterator& shape_start =
20+ bottom[0 ]->shape ().begin ();
21+ const vector<int >::const_iterator& shape_end = bottom[0 ]->shape ().end ();
22+ vector<int > bias_shape (shape_start, shape_end);
23+ this ->blobs_ [0 ].reset (new Blob<Dtype>(bias_shape));
24+
25+ this ->param_propagate_down_ .resize (this ->blobs_ .size (), true );
26+ }
27+ }
28+
929template <typename Dtype>
1030void PowLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
1131 const vector<Blob<Dtype>*>& top) {
You can’t perform that action at this time.
0 commit comments