I am using TensorFlow-Slim and I've added some code lines in eval_image_classifier.py (located in /models/slim/) for computing TP, TN, FP and FN. However, computing Accuracy = (TP + TN) / (TP + FP + FN + TN) is not equal to the accuracy given by slim.metrics.streaming_accuracy(predictions, labels).
I have changed standard code from this:
names_to_values, names_to_updates = slim.metrics.aggregate_metric_map({
'Accuracy': slim.metrics.streaming_accuracy(predictions, labels),
'Recall_5': slim.metrics.streaming_recall_at_k(
logits, labels, 5),
})
...to this:
names_to_values, names_to_updates = slim.metrics.aggregate_metric_map({
'Accuracy': slim.metrics.streaming_accuracy(predictions, labels),
'TruePositives': slim.metrics.streaming_true_positives(predictions, labels),
'TrueNegatives': slim.metrics.streaming_true_negatives(predictions, labels),
'FalsePositives': slim.metrics.streaming_false_positives(predictions, labels),
'FalseNegatives': slim.metrics.streaming_false_negatives(predictions, labels),
'Recall_5': slim.metrics.streaming_recall_at_k(
logits, labels, 5),
})
Output:
I tensorflow/core/kernels/logging_ops.cc:79] eval/TruePositives[322]
I tensorflow/core/kernels/logging_ops.cc:79] eval/TrueNegatives[72]
I tensorflow/core/kernels/logging_ops.cc:79] eval/FalsePositives[4]
I tensorflow/core/kernels/logging_ops.cc:79] eval/FalseNegatives[2]
I tensorflow/core/kernels/logging_ops.cc:79] eval/Accuracy[0.9525]
I tensorflow/core/kernels/logging_ops.cc:79] eval/Recall_5[1]
I've tested the finetune_resnet_v1_50_on_flowers.sh script (located in /models/slim/scripts) without changing anything (cloned on 12.04.2017).
I'm not able to find my mistake. I would be very pleased to receive your answers, opinions or concrete proposals to this problem.
CUDA version: release 8.0, V8.0.53
TensorFlow installed from binary, tested versions: 1.0.1 and 1.1.0rc1
GPU: NVIDIA Tesla P100 (SXM2)