From 36fe5015581d3d54f25396a42e29cadc627dd8fa Mon Sep 17 00:00:00 2001 From: atlas Date: Thu, 23 Apr 2020 14:04:41 +0200 Subject: [PATCH] modelinfos --- service/examples/mpg/main.cpp | 2 + service/include/ModelInfos.h | 96 +++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 service/include/ModelInfos.h diff --git a/service/examples/mpg/main.cpp b/service/examples/mpg/main.cpp index 6469080..ef21ffb 100644 --- a/service/examples/mpg/main.cpp +++ b/service/examples/mpg/main.cpp @@ -18,6 +18,8 @@ int main() { ModelInfos mInfos("../ModelInfo.txt"); mInfos.show(); + mInfos.parse(); + // Create Tensors Tensor input(m, "x"); Tensor prediction(m, "Identity"); diff --git a/service/include/ModelInfos.h b/service/include/ModelInfos.h new file mode 100644 index 0000000..391f503 --- /dev/null +++ b/service/include/ModelInfos.h @@ -0,0 +1,96 @@ +/* +* class ModelInfos.h +* user: laitassou +* description +*/ + +#pragma once + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +template class ModelInfos +{ + public: + struct Stats + { + T mean; + T std; + }; + + ModelInfos(const std::string & name):input_depth(0) + { + + try + { + //std::stringstream ss; + // send your JSON above to the parser below, but populate ss first + //boost::property_tree::ptree pt; + + std::ifstream jsonFile(name); + boost::property_tree::read_json(jsonFile, pt_json); + + } + catch (std::exception const& e) + { + std::cout<< e.what()<< std::endl; + } + } + const std::string & get(const std::string &label) const + { + auto it = labels.find(label); + if(it == labels.end()) + { + return std::string(); + } + else{ + return it->second; + } + } + + size_t get_depth()const + { + return input_depth; + } + + void show(void) const + { + using boost::property_tree::ptree; + ptree::const_iterator end = pt_json.end(); + for (ptree::const_iterator it = pt_json.begin(); it != end; ++it) { + std::cout << it->first << " :" <second; + for(auto & rr :row) + std::cout << rr.first << ":" << rr.second.data()<< std::endl; + } + } + void parse(void) + { + using boost::property_tree::ptree; + ptree::const_iterator end = pt_json.end(); + for (ptree::const_iterator it = pt_json.begin(); it != end; ++it) { + auto row = it->second; + for(auto & rr :row) + { + input_depth++; + std::cout << rr.first << ", input_depth :" << input_depth < labels; + boost::property_tree::ptree pt_json; +}; \ No newline at end of file