Commit d05e9ce4 authored by hugopiq's avatar hugopiq
Browse files

add library

parent e3bec556
......@@ -115,13 +115,13 @@ int ANNModelWeights(std::map<FTYPE, DataVector>
softmaxF(X3);
auto max = std::max_element(std::begin(X3), std::end(X3));
for (size_t i = 0; i < X3.size(); i++)
for (int i = 0; i < X3.size(); i++)
{
if (*max == X3[i])
{
return i;
}
}
return 0;
return 10;
}
#endif
\ No newline at end of file
......@@ -16,6 +16,6 @@ int main(int argc, char **argv)
}
std::map<FTYPE, DataVector> features = compute_features_for(file_path);
int result = ANNModelWeights(features);
std::cout << result;
std::cout << genres[result];
return 0;
}
\ No newline at end of file
......@@ -7,7 +7,8 @@
#include <complex>
#include <vector>
#include <map>
#include <string>
typedef double real;
typedef std::complex<real> Complex;
typedef std::vector<real> DataVector;
......
......@@ -3,14 +3,14 @@
#include "etypes.h"
constexpr std::size_t N = 512; // WINDOW SIZE
constexpr real Fs = 22050.0; // SAMPLING FREQUENCY
constexpr std::size_t N = 512; // WINDOW SIZE
constexpr real Fs = 22050.0; // SAMPLING FREQUENCY
const std::size_t FFT_SIZE = N / 2;
constexpr std::size_t CLASS_N = 10; // CLASS NUMBER
constexpr std::size_t FEAT_N = 512; // FEATURES NUMBER STFT (if AVG and STD)
constexpr std::size_t CLASS_N = 10; // CLASS NUMBER
constexpr std::size_t FEAT_N = 512; // FEATURES NUMBER STFT (if AVG and STD)
constexpr std::size_t OVO_CLASS_N = CLASS_N * (CLASS_N - 1) / 2; // One Versus One CLASS NUMBER
constexpr std::size_t MEL_N = 26;
constexpr std::size_t MEL_FILTERS_N = MEL_N - 2;
std::map<int, std::string> genres = {{0, "blues"}, {1, "classical"}, {2, "country"}, {3, "disco"}, {4, "hiphop"}, {5, "jazz"}, {6, "metal"}, {7, "pop"}, {8, "reggae"}, {9, "rock"}, {10, "none"}};
#endif //GLOBAL_H
#endif // GLOBAL_H
......@@ -1039,7 +1039,7 @@ int SVMModelAlgo(std::map<FTYPE, DataVector> &features)
featureVector.insert(featureVector.end(), features[FTYPE::BINSTDEV].begin(), features[FTYPE::BINSTDEV].end());
std::transform(featureVector.cbegin(), featureVector.cend(), featureVector.begin(), [&, indexM = -1, indexS = -1](real c) mutable
{indexM++;indexS++;return (c - meanNorm[indexM]) / stdNorm[indexS]; });
int nbClass = 1000;
int nbClass = 10;
real hyperplanResult;
for (size_t i = 0; i < featureVector.size(); i++)
{
......
......@@ -27,7 +27,7 @@ int SVMModelWeights(std::map<FTYPE, DataVector>
return (c - meanFeature[indexM]) / stdFeature[indexS];
});
// SVM
int nbClass = 1000;
int nbClass = 10;
for (size_t i = 0; i < coefs.size(); i++)
{
// foreach class ie ligne coef avec intercep (ordonee)
......
......@@ -17,8 +17,8 @@ int main(int argc, char **argv)
}
std::map<FTYPE, DataVector> features = compute_features_for(file_path);
int result2 = SVMModelWeights(features);
std::cout << result2 << std::endl;
std::cout << genres[result2] << std::endl;
int result3 = SVMModelAlgo(features);
std::cout << result3 << std::endl;
std::cout << genres[result3] << std::endl;
return 0;
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment