Éanna Ó Catháin | a4247d5 | 2019-05-08 14:00:45 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include <vector> |
| 7 | #include <map> |
| 8 | #include <boost/log/trivial.hpp> |
| 9 | #include "ModelAccuracyChecker.hpp" |
| 10 | |
| 11 | namespace armnnUtils |
| 12 | { |
| 13 | |
| 14 | armnnUtils::ModelAccuracyChecker::ModelAccuracyChecker(const std::map<std::string, int>& validationLabels) |
| 15 | : m_GroundTruthLabelSet(validationLabels){} |
| 16 | |
| 17 | float ModelAccuracyChecker::GetAccuracy(unsigned int k) |
| 18 | { |
| 19 | if(k > 10) { |
| 20 | BOOST_LOG_TRIVIAL(info) << "Accuracy Tool only supports a maximum of Top 10 Accuracy. " |
| 21 | "Printing Top 10 Accuracy result!"; |
| 22 | k = 10; |
| 23 | } |
| 24 | unsigned int total = 0; |
| 25 | for (unsigned int i = k; i > 0; --i) |
| 26 | { |
| 27 | total += m_TopK[i]; |
| 28 | } |
| 29 | return static_cast<float>(total * 100) / static_cast<float>(m_ImagesProcessed); |
| 30 | } |
| 31 | } |