summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrzemysław Dolata <snowball91b@gmail.com>2017-11-29 11:28:31 (GMT)
committerGitHub <noreply@github.com>2017-11-29 11:28:31 (GMT)
commit99466224dac86ddb86296b1e727794fb836bd80f (patch)
tree736edc46235b805ab913862c69a01f225c73aca7
parente93b5e20356689654995e0bf2ce9cbb285a250f3 (diff)
parent3be5297ba3c512abca0dad4541ecb1f78d640542 (diff)
downloadcaffe-99466224dac86ddb86296b1e727794fb836bd80f.zip
caffe-99466224dac86ddb86296b1e727794fb836bd80f.tar.gz
caffe-99466224dac86ddb86296b1e727794fb836bd80f.tar.bz2
Merge pull request #6084 from Noiredd/accuracy-count-fix
Added count==0 safeguard to CPU accuracy calculation
-rw-r--r--src/caffe/layers/accuracy_layer.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/caffe/layers/accuracy_layer.cpp b/src/caffe/layers/accuracy_layer.cpp
index 392829e..b6d95b5 100644
--- a/src/caffe/layers/accuracy_layer.cpp
+++ b/src/caffe/layers/accuracy_layer.cpp
@@ -86,7 +86,7 @@ void AccuracyLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
}
// LOG(INFO) << "Accuracy: " << accuracy;
- top[0]->mutable_cpu_data()[0] = accuracy / count;
+ top[0]->mutable_cpu_data()[0] = (count == 0) ? 0 : (accuracy / count);
if (top.size() > 1) {
for (int i = 0; i < top[1]->count(); ++i) {
top[1]->mutable_cpu_data()[i] =