MCPcopy Create free account
hub / github.com/OAID/Tengine / Argmax

Function Argmax

examples/caffe_wrapper/cpp_classification/classification.cpp:87–98  ·  view source on GitHub ↗

Return the indices of the top N values of vector v. */

Source from the content-addressed store, hash-verified

85
86/* Return the indices of the top N values of vector v. */
87static std::vector<int> Argmax(const std::vector<float>& v, int N)
88{
89 std::vector<std::pair<float, int>> pairs;
90 for(size_t i = 0; i < v.size(); ++i)
91 pairs.push_back(std::make_pair(v[i], i));
92 std::partial_sort(pairs.begin(), pairs.begin() + N, pairs.end(), PairCompare);
93
94 std::vector<int> result;
95 for(int i = 0; i < N; ++i)
96 result.push_back(pairs[i].second);
97 return result;
98}
99
100/* Return the top N predictions. */
101std::vector<Prediction> Classifier::Classify(const cv::Mat& img, int N)

Callers 1

ClassifyMethod · 0.70

Calls 3

beginMethod · 0.80
endMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected