MCPcopy Create free account
hub / github.com/BVLC/caffe / Argmax

Function Argmax

examples/cpp_classification/classification.cpp:92–102  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 1

ClassifyMethod · 0.85

Calls 3

sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected