From 7908de7ea914c1c968af01880357791a300483be Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Wed, 27 Jun 2018 12:34:20 +0100 Subject: COMPMID-1309: Add result validation on full network validation Change-Id: I5a7e2b198593c782eb812dd3f013ee2b91dc895f Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/137627 Tested-by: Jenkins Reviewed-by: Giorgio Arena Reviewed-by: Anthony Barbier --- utils/GraphUtils.h | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'utils/GraphUtils.h') diff --git a/utils/GraphUtils.h b/utils/GraphUtils.h index 349d8558fc..768c608d26 100644 --- a/utils/GraphUtils.h +++ b/utils/GraphUtils.h @@ -185,7 +185,7 @@ public: * @param[in] start (Optional) Start range * @param[in] end (Optional) End range * - * @note + * @note Range is defined as [start, end] */ ValidationInputAccessor(const std::string &image_list, std::string images_path, @@ -203,6 +203,49 @@ private: size_t _offset; }; +/** Output Accessor used for network validation */ +class ValidationOutputAccessor final : public graph::ITensorAccessor +{ +public: + /** Default Constructor + * + * @param[in] image_list File containing all the images and labels results + * @param[in] top_n (Optional) Top N accuracy (Defaults to 5) + * @param[out] output_stream (Optional) Output stream (Defaults to the standard output stream) + * @param[in] start (Optional) Start range + * @param[in] end (Optional) End range + * + * @note Range is defined as [start, end] + */ + ValidationOutputAccessor(const std::string &image_list, + size_t top_n = 5, + std::ostream &output_stream = std::cout, + unsigned int start = 0, + unsigned int end = 0); + /** Reset accessor state */ + void reset(); + + // Inherited methods overriden: + bool access_tensor(ITensor &tensor) override; + +private: + /** Access predictions of the tensor + * + * @tparam T Tensor elements type + * + * @param[in] tensor Tensor to read the predictions from + */ + template + std::vector access_predictions_tensor(ITensor &tensor); + +private: + std::vector _results; + std::ostream &_output_stream; + size_t _top_n; + size_t _offset; + size_t _positive_samples; +}; + /** Result accessor class */ class TopNPredictionsAccessor final : public graph::ITensorAccessor { -- cgit v1.2.1