Fixed the GPU implementation of EuclideanLoss to report the loss to the top layer
authorAlireza Shafaei <alireza@shafaei.net>
Tue, 12 Aug 2014 20:54:51 +0000 (13:54 -0700)
committerEvan Shelhamer <shelhamer@imaginarynumber.net>
Wed, 13 Aug 2014 15:56:43 +0000 (08:56 -0700)
src/caffe/layers/euclidean_loss_layer.cu

index dd14f19..f4dfd0b 100644 (file)
@@ -19,6 +19,9 @@ Dtype EuclideanLossLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
   Dtype dot;
   caffe_gpu_dot(count, diff_.gpu_data(), diff_.gpu_data(), &dot);
   Dtype loss = dot / bottom[0]->num() / Dtype(2);
+  if (top->size() == 1) {
+    (*top)[0]->mutable_cpu_data()[0] = loss;
+  }
   return loss;
 }