Skip to content

Commit

Permalink
BVLC#38: pre-class accuracy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Rassadin committed May 13, 2016
1 parent aec1522 commit d904061
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/caffe/layers/accuracy_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,17 @@ void AccuracyLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
top[0]->mutable_cpu_data()[0] = accuracy / count;
if (top.size() >= 2) {
for (int i = 0; i < num_labels; ++i) {
top[1]->mutable_cpu_data()[i] = accuracies[i] / nums[i];
if (nums[i] == 0) {
if (accuracies[i] == 0) {
top[1]->mutable_cpu_data()[i] = 1;
}
else {
top[1]->mutable_cpu_data()[i] = 0;
}
}
else {
top[1]->mutable_cpu_data()[i] = accuracies[i] / nums[i];
}
}
}
// Accuracy layer should not be used as a loss function.
Expand Down

0 comments on commit d904061

Please sign in to comment.