@@ -31,6 +31,11 @@ class AccuracyLayer : public Layer<Dtype> {
3131 : Layer<Dtype>(param) {}
3232 virtual void SetUp (const vector<Blob<Dtype>*>& bottom,
3333 vector<Blob<Dtype>*>* top);
34+ virtual Dtype Forward (const vector<Blob<Dtype>*>& bottom,
35+ vector<Blob<Dtype>*>* top);
36+ virtual void Backward (const vector<Blob<Dtype>*>& top,
37+ const vector<bool >& propagate_down,
38+ vector<Blob<Dtype>*>* bottom) { NOT_IMPLEMENTED; }
3439
3540 virtual inline LayerParameter_LayerType type () const {
3641 return LayerParameter_LayerType_ACCURACY;
@@ -40,13 +45,6 @@ class AccuracyLayer : public Layer<Dtype> {
4045 virtual inline int ExactNumTopBlobs () const { return 1 ; }
4146
4247 protected:
43- virtual Dtype Forward_cpu (const vector<Blob<Dtype>*>& bottom,
44- vector<Blob<Dtype>*>* top);
45- virtual void Backward_cpu (const vector<Blob<Dtype>*>& top,
46- const vector<bool >& propagate_down, vector<Blob<Dtype>*>* bottom) {
47- NOT_IMPLEMENTED;
48- }
49-
5048 int top_k_;
5149};
5250
@@ -112,15 +110,14 @@ class HingeLossLayer : public LossLayer<Dtype> {
112110 explicit HingeLossLayer (const LayerParameter& param)
113111 : LossLayer<Dtype>(param) {}
114112
113+ virtual Dtype Forward (const vector<Blob<Dtype>*>& bottom,
114+ vector<Blob<Dtype>*>* top);
115+ virtual void Backward (const vector<Blob<Dtype>*>& top,
116+ const vector<bool >& propagate_down, vector<Blob<Dtype>*>* bottom);
117+
115118 virtual inline LayerParameter_LayerType type () const {
116119 return LayerParameter_LayerType_HINGE_LOSS;
117120 }
118-
119- protected:
120- virtual Dtype Forward_cpu (const vector<Blob<Dtype>*>& bottom,
121- vector<Blob<Dtype>*>* top);
122- virtual void Backward_cpu (const vector<Blob<Dtype>*>& top,
123- const vector<bool >& propagate_down, vector<Blob<Dtype>*>* bottom);
124121};
125122
126123/* InfogainLossLayer
@@ -154,16 +151,14 @@ class MultinomialLogisticLossLayer : public LossLayer<Dtype> {
154151 : LossLayer<Dtype>(param) {}
155152 virtual void FurtherSetUp (const vector<Blob<Dtype>*>& bottom,
156153 vector<Blob<Dtype>*>* top);
154+ virtual Dtype Forward (const vector<Blob<Dtype>*>& bottom,
155+ vector<Blob<Dtype>*>* top);
156+ virtual void Backward (const vector<Blob<Dtype>*>& top,
157+ const vector<bool >& propagate_down, vector<Blob<Dtype>*>* bottom);
157158
158159 virtual inline LayerParameter_LayerType type () const {
159160 return LayerParameter_LayerType_MULTINOMIAL_LOGISTIC_LOSS;
160161 }
161-
162- protected:
163- virtual Dtype Forward_cpu (const vector<Blob<Dtype>*>& bottom,
164- vector<Blob<Dtype>*>* top);
165- virtual void Backward_cpu (const vector<Blob<Dtype>*>& top,
166- const vector<bool >& propagate_down, vector<Blob<Dtype>*>* bottom);
167162};
168163
169164/* SigmoidCrossEntropyLossLayer
@@ -177,21 +172,16 @@ class SigmoidCrossEntropyLossLayer : public LossLayer<Dtype> {
177172 sigmoid_output_(new Blob<Dtype>()) {}
178173 virtual void FurtherSetUp (const vector<Blob<Dtype>*>& bottom,
179174 vector<Blob<Dtype>*>* top);
175+ virtual Dtype Forward (const vector<Blob<Dtype>*>& bottom,
176+ vector<Blob<Dtype>*>* top);
177+ virtual void Backward (const vector<Blob<Dtype>*>& top,
178+ const vector<bool >& propagate_down, vector<Blob<Dtype>*>* bottom);
180179
181180 virtual inline LayerParameter_LayerType type () const {
182181 return LayerParameter_LayerType_SIGMOID_CROSS_ENTROPY_LOSS;
183182 }
184183
185184 protected:
186- virtual Dtype Forward_cpu (const vector<Blob<Dtype>*>& bottom,
187- vector<Blob<Dtype>*>* top);
188- virtual Dtype Forward_gpu (const vector<Blob<Dtype>*>& bottom,
189- vector<Blob<Dtype>*>* top);
190- virtual void Backward_cpu (const vector<Blob<Dtype>*>& top,
191- const vector<bool >& propagate_down, vector<Blob<Dtype>*>* bottom);
192- virtual void Backward_gpu (const vector<Blob<Dtype>*>& top,
193- const vector<bool >& propagate_down, vector<Blob<Dtype>*>* bottom);
194-
195185 shared_ptr<SigmoidLayer<Dtype> > sigmoid_layer_;
196186 // sigmoid_output stores the output of the sigmoid layer.
197187 shared_ptr<Blob<Dtype> > sigmoid_output_;
@@ -218,10 +208,10 @@ class SoftmaxWithLossLayer : public Layer<Dtype> {
218208 : Layer<Dtype>(param), softmax_layer_(new SoftmaxLayer<Dtype>(param)) {}
219209 virtual void SetUp (const vector<Blob<Dtype>*>& bottom,
220210 vector<Blob<Dtype>*>* top);
221- virtual Dtype Forward (const vector<Blob<Dtype>*>& bottom,
222- vector<Blob<Dtype>*>* top);
223- virtual void Backward (const vector<Blob<Dtype>*>& top,
224- const vector<bool >& propagate_down, vector<Blob<Dtype>*>* bottom);
211+ virtual Dtype Forward (const vector<Blob<Dtype>*>& bottom,
212+ vector<Blob<Dtype>*>* top);
213+ virtual void Backward (const vector<Blob<Dtype>*>& top,
214+ const vector<bool >& propagate_down, vector<Blob<Dtype>*>* bottom);
225215
226216 virtual inline LayerParameter_LayerType type () const {
227217 return LayerParameter_LayerType_SOFTMAX_LOSS;
0 commit comments