Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
lib4neuro
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MolDyn
lib4neuro
Commits
c930da15
Commit
c930da15
authored
6 years ago
by
Martin Beseda
Browse files
Options
Downloads
Patches
Plain Diff
FIX: MSE is now evaluated againts de-normalized data
parent
db092dd4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ErrorFunction/ErrorFunctions.cpp
+48
-11
48 additions, 11 deletions
src/ErrorFunction/ErrorFunctions.cpp
with
48 additions
and
11 deletions
src/ErrorFunction/ErrorFunctions.cpp
+
48
−
11
View file @
c930da15
...
...
@@ -111,6 +111,7 @@ namespace lib4neuro {
size_t
n_elements
=
data
->
size
();
//TODO instead use something smarter
std
::
vector
<
std
::
vector
<
double
>>
outputs
(
data
->
size
());
std
::
vector
<
double
>
output
(
dim_out
);
COUT_DEBUG
(
"Evaluation of the error function MSE on the given data-set (format 'data-set element index' 'input'"
...
...
@@ -127,8 +128,16 @@ namespace lib4neuro {
output
,
weights
);
/* Compute difference for every element of the output vector */
outputs
.
at
(
i
)
=
output
;
}
if
(
data_set
->
is_normalized
())
{
data_set
->
de_normalize
();
}
for
(
auto
i
=
0
;
i
<
data
->
size
();
i
++
)
{
/* Compute difference for every element of the output vector */
#ifdef L4N_DEBUG
std
::
stringstream
ss_input
;
for
(
auto
j
=
0
;
j
<
dim_in
-
1
;
j
++
)
{
...
...
@@ -139,16 +148,18 @@ namespace lib4neuro {
std
::
stringstream
ss_real_output
;
std
::
stringstream
ss_predicted_output
;
#endif
double
denormalized_output
;
for
(
size_t
j
=
0
;
j
<
dim_out
;
++
j
)
{
denormalized_output
=
data_set
->
get_normalization_strategy
()
->
de_normalize
(
outputs
.
at
(
i
).
at
(
j
));
#ifdef L4N_DEBUG
ss_real_output
<<
data
->
at
(
i
).
second
.
at
(
j
);
ss_predicted_output
<<
output
.
at
(
j
)
;
ss_predicted_output
<<
denormalized_
output
;
#endif
val
=
output
.
at
(
j
)
-
data
->
at
(
i
).
second
.
at
(
j
);
val
=
denormalized_
output
-
data
->
at
(
i
).
second
.
at
(
j
);
error
+=
val
*
val
;
output_norm
+=
output
.
at
(
j
)
*
output
.
at
(
j
)
;
output_norm
+=
denormalized_output
*
denormalized_output
;
}
#ifdef L4N_DEBUG
COUT_DEBUG
(
i
<<
": "
...
...
@@ -184,6 +195,7 @@ namespace lib4neuro {
std
::
vector
<
std
::
pair
<
std
::
vector
<
double
>
,
std
::
vector
<
double
>>>*
data
=
data_set
->
get_data
();
//TODO instead use something smarter
std
::
vector
<
std
::
vector
<
double
>>
outputs
(
data
->
size
());
std
::
vector
<
double
>
output
(
dim_out
);
COUT_DEBUG
(
...
...
@@ -204,23 +216,32 @@ namespace lib4neuro {
output
,
weights
);
outputs
.
at
(
i
)
=
output
;
}
if
(
data_set
->
is_normalized
())
{
data_set
->
de_normalize
();
}
for
(
auto
i
=
0
;
i
<
data
->
size
();
i
++
)
{
/* Compute difference for every element of the output vector */
double
denormalized_output
;
for
(
size_t
j
=
0
;
j
<
dim_out
;
++
j
)
{
denormalized_output
=
data_set
->
get_normalization_strategy
()
->
de_normalize
(
outputs
.
at
(
i
).
at
(
j
));
COUT_DEBUG
(
"Element "
<<
i
<<
": "
<<
data
->
at
(
i
).
first
.
at
(
j
)
<<
" "
<<
data
->
at
(
i
).
second
.
at
(
j
)
<<
" "
<<
output
.
at
(
j
)
<<
std
::
endl
);
<<
denormalized_
output
<<
std
::
endl
);
ofs
<<
data
->
at
(
i
).
first
.
at
(
j
)
<<
" "
<<
data
->
at
(
i
).
second
.
at
(
j
)
<<
" "
<<
output
.
at
(
j
)
<<
std
::
endl
;
<<
denormalized_
output
<<
std
::
endl
;
val
=
output
.
at
(
j
)
-
data
->
at
(
i
).
second
.
at
(
j
);
val
=
denormalized_
output
-
data
->
at
(
i
).
second
.
at
(
j
);
error
+=
val
*
val
;
}
ofs
<<
std
::
endl
;
}
ofs
.
close
();
...
...
@@ -236,12 +257,14 @@ namespace lib4neuro {
std
::
vector
<
std
::
pair
<
std
::
vector
<
double
>
,
std
::
vector
<
double
>>>*
data
=
data_set
->
get_data
();
//TODO instead use something smarter
std
::
vector
<
std
::
vector
<
double
>>
outputs
(
data
->
size
());
std
::
vector
<
double
>
output
(
dim_out
);
COUT_DEBUG
(
"Evaluation of the error function MSE on the given data-set (format 'input' 'real output' 'predicted output'):"
<<
std
::
endl
);
/* Compute predicted outputs */
for
(
auto
i
=
0
;
i
<
data
->
size
();
i
++
)
{
// Iterate through every element in the test set
/* Compute the net output and store it into 'output' variable */
...
...
@@ -249,17 +272,31 @@ namespace lib4neuro {
output
,
weights
);
outputs
.
at
(
i
)
=
output
;
}
/* De-normalize data-set, if it's normalized */
if
(
data_set
->
is_normalized
())
{
data_set
->
de_normalize
();
}
/* Evaluate the prediction error on de-normalized data */
for
(
auto
i
=
0
;
i
<
data
->
size
();
i
++
)
{
/* Compute difference for every element of the output vector */
for
(
size_t
j
=
0
;
j
<
dim_out
;
++
j
)
{
double
denormalized_output
;
for
(
auto
j
=
0
;
j
<
dim_out
;
++
j
)
{
denormalized_output
=
data_set
->
get_normalization_strategy
()
->
de_normalize
(
outputs
.
at
(
i
).
at
(
j
));
COUT_DEBUG
(
"Element "
<<
i
<<
": "
<<
data
->
at
(
i
).
first
.
at
(
j
)
<<
" "
<<
data
->
at
(
i
).
second
.
at
(
j
)
<<
" "
<<
output
.
at
(
j
)
<<
std
::
endl
);
<<
denormalized_
output
<<
std
::
endl
);
val
=
output
.
at
(
j
)
-
data
->
at
(
i
).
second
.
at
(
j
);
val
=
denormalized_
output
-
data
->
at
(
i
).
second
.
at
(
j
);
error
+=
val
*
val
;
}
}
return
error
/
n_elements
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment