From 98b8515b56eb6aac97db61df06da1cf196e39353 Mon Sep 17 00:00:00 2001 From: Yangqing Jia Date: Fri, 25 Oct 2013 13:55:23 -0700 Subject: bugfix --- src/caffe/layers/bnll_layer.cu | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/caffe/layers/bnll_layer.cu b/src/caffe/layers/bnll_layer.cu index c9a33ed5..fd261a35 100644 --- a/src/caffe/layers/bnll_layer.cu +++ b/src/caffe/layers/bnll_layer.cu @@ -30,9 +30,10 @@ Dtype BNLLLayer::Backward_cpu(const vector*>& top, const Dtype* top_diff = top[0]->cpu_diff(); Dtype* bottom_diff = (*bottom)[0]->mutable_cpu_diff(); const int count = (*bottom)[0]->count(); + Dtype expval; for (int i = 0; i < count; ++i) { - Dtype expval = exp(min(bottom_data[index], Dtype(kBNLL_THRESHOLD))); - bottom_diff[index] = top_diff[index] * expval / (expval + 1.); + expval = exp(min(bottom_data[i], Dtype(kBNLL_THRESHOLD))); + bottom_diff[i] = top_diff[i] * expval / (expval + 1.); } } return Dtype(0); @@ -42,7 +43,7 @@ template __global__ void BNLLForward(const int n, const Dtype* in, Dtype* out) { int index = threadIdx.x + blockIdx.x * blockDim.x; if (index < n) { - out[index] = log(1. + exp(min(in[index], Dtype(kBNLL_THRESHOLD))); + out[index] = log(1. + exp(min(in[index], Dtype(kBNLL_THRESHOLD)))); } } -- cgit v1.2.3