diff options
author | Yangqing Jia <jiayq84@gmail.com> | 2013-10-27 10:11:23 -0700 |
---|---|---|
committer | Yangqing Jia <jiayq84@gmail.com> | 2013-10-27 10:11:23 -0700 |
commit | cf301543fb2a62ba26dbb9307356e78634519123 (patch) | |
tree | 7e2f425a4bcb5078e29fdbd272b18c16c91b69df /src | |
parent | 0d752824e8c2c1dc1d23ca60b9ef28d28329fbc5 (diff) | |
download | caffe-cf301543fb2a62ba26dbb9307356e78634519123.tar.gz caffe-cf301543fb2a62ba26dbb9307356e78634519123.tar.bz2 caffe-cf301543fb2a62ba26dbb9307356e78634519123.zip |
bugfix and made the C++ interface for creating leveldb
Diffstat (limited to 'src')
-rw-r--r-- | src/caffe/layers/bnll_layer.cu | 8 | ||||
-rw-r--r-- | src/caffe/util/io.cpp | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/caffe/layers/bnll_layer.cu b/src/caffe/layers/bnll_layer.cu index fd261a35..2c06a63d 100644 --- a/src/caffe/layers/bnll_layer.cu +++ b/src/caffe/layers/bnll_layer.cu @@ -17,7 +17,9 @@ void BNLLLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom, Dtype* top_data = (*top)[0]->mutable_cpu_data(); const int count = bottom[0]->count(); for (int i = 0; i < count; ++i) { - top_data[i] = log(1. + exp(min(bottom_data[i], Dtype(kBNLL_THRESHOLD)))); + top_data[i] = bottom_data[i] > 0 ? + bottom_data[i] + log(1. + exp(-bottom_data[i])) : + log(1. + exp(bottom_data[i])); } } @@ -43,7 +45,9 @@ template <typename Dtype> __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] = in[index] > 0 ? + in[index] + log(1. + exp(-in[index])) : + log(1. + exp(in[index])); } } diff --git a/src/caffe/util/io.cpp b/src/caffe/util/io.cpp index 5e5510f5..a3c520f0 100644 --- a/src/caffe/util/io.cpp +++ b/src/caffe/util/io.cpp @@ -67,7 +67,7 @@ void WriteProtoToBinaryFile(const Message& proto, const char* filename) { void ReadImageToDatum(const string& filename, const int label, Datum* datum) { - Mat cv_img; + cv::Mat cv_img; cv_img = cv::imread(filename, CV_LOAD_IMAGE_COLOR); CHECK(cv_img.data) << "Could not open or find the image."; datum->set_channels(3); @@ -80,7 +80,7 @@ void ReadImageToDatum(const string& filename, const int label, Datum* datum) { for (int c = 0; c < 3; ++c) { for (int h = 0; h < cv_img.rows; ++h) { for (int w = 0; w < cv_img.cols; ++w) { - datum_string->push_back(static_cast<char>(cv_img.at<Vec3b>(h, w)[c])); + datum_string->push_back(static_cast<char>(cv_img.at<cv::Vec3b>(h, w)[c])); } } } |