LossLayer output is 0D (scalar)
authorJeff Donahue <jeff.donahue@gmail.com>
Wed, 26 Nov 2014 07:46:57 +0000 (23:46 -0800)
committerJeff Donahue <jeff.donahue@gmail.com>
Tue, 3 Mar 2015 23:55:13 +0000 (15:55 -0800)
src/caffe/layers/loss_layer.cpp

index a5b6d11..3496a5c 100644 (file)
@@ -24,7 +24,8 @@ void LossLayer<Dtype>::Reshape(
     const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
   CHECK_EQ(bottom[0]->num(), bottom[1]->num())
       << "The data and label should have the same number.";
-  top[0]->Reshape(1, 1, 1, 1);
+  vector<int> loss_shape(0);  // Loss layers output a scalar; 0 axes.
+  top[0]->Reshape(loss_shape);
 }
 
 INSTANTIATE_CLASS(LossLayer);