Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Estelle ARRICAU
Embedded Machine Learning
Commits
d05e9ce4
Commit
d05e9ce4
authored
Jan 07, 2022
by
hugopiq
Browse files
add library
parent
e3bec556
Changes
7
Hide whitespace changes
Inline
Side-by-side
ANN/apply_ANN_weights.h
View file @
d05e9ce4
...
...
@@ -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
(
in
t
i
=
0
;
i
<
X3
.
size
();
i
++
)
{
if
(
*
max
==
X3
[
i
])
{
return
i
;
}
}
return
0
;
return
1
0
;
}
#endif
\ No newline at end of file
ANN/main.cpp
View file @
d05e9ce4
...
...
@@ -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
Helpers/etypes.h
View file @
d05e9ce4
...
...
@@ -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
;
...
...
Helpers/globals.h
View file @
d05e9ce4
...
...
@@ -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
SVM/apply_SVM_algo.h
View file @
d05e9ce4
...
...
@@ -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
=
10
00
;
int
nbClass
=
10
;
real
hyperplanResult
;
for
(
size_t
i
=
0
;
i
<
featureVector
.
size
();
i
++
)
{
...
...
SVM/apply_SVM_weights.h
View file @
d05e9ce4
...
...
@@ -27,7 +27,7 @@ int SVMModelWeights(std::map<FTYPE, DataVector>
return
(
c
-
meanFeature
[
indexM
])
/
stdFeature
[
indexS
];
});
// SVM
int
nbClass
=
10
00
;
int
nbClass
=
10
;
for
(
size_t
i
=
0
;
i
<
coefs
.
size
();
i
++
)
{
// foreach class ie ligne coef avec intercep (ordonee)
...
...
SVM/main.cpp
View file @
d05e9ce4
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment