Skip to content
Snippets Groups Projects
Commit 8ae44713 authored by Jordi Inglada's avatar Jordi Inglada
Browse files

ENH: add comment and simplify vector copy

parent a61ab795
Branches
Tags
No related merge requests found
......@@ -135,12 +135,12 @@ template <class T> void ListSampleToSharkVector(const T * listSample, std::vecto
}
/** Shark assumes that labels are 0 ... (nbClasses-1). This function modifies the labels contained in the input vector and returns a vector with size = nbClasses which allows the translation from the normalised labels to the new ones oldLabel = dictionary[newLabel].
When we want to generate the image containing the probability for each class, we need to ensure that the probabilities are in the correct order wrt the incoming labels. We therefore sort the labels before building the encoding.
*/
template <typename T> void NormalizeLabelsAndGetDictionary(std::vector<T>& labels,
std::vector<T>& dictionary)
{
std::vector<T> sorted_labels;
std::copy(std::begin(labels), std::end(labels), std::back_inserter(sorted_labels));
std::vector<T> sorted_labels = labels;
std::sort(std::begin(sorted_labels), std::end(sorted_labels));
auto last = std::unique(std::begin(sorted_labels), std::end(sorted_labels));
sorted_labels.erase(last, std::end(sorted_labels));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment