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
6389037f
Commit
6389037f
authored
6 years ago
by
Martin Beseda
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Added 'parameters' parameter to the method calculate_single_residual.
parent
4d04630e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ErrorFunction/ErrorFunctions.cpp
+6
-4
6 additions, 4 deletions
src/ErrorFunction/ErrorFunctions.cpp
src/ErrorFunction/ErrorFunctions.h
+4
-2
4 additions, 2 deletions
src/ErrorFunction/ErrorFunctions.h
with
10 additions
and
6 deletions
src/ErrorFunction/ErrorFunctions.cpp
+
6
−
4
View file @
6389037f
...
...
@@ -367,12 +367,14 @@ namespace lib4neuro {
}
}
double
MSE
::
calculate_single_residual
(
std
::
vector
<
double
>*
input
,
std
::
vector
<
double
>*
output
)
{
double
MSE
::
calculate_single_residual
(
std
::
vector
<
double
>*
input
,
std
::
vector
<
double
>*
output
,
std
::
vector
<
double
>*
parameters
)
{
//TODO maybe move to the general ErrorFunction
//TODO check input vector sizes - they HAVE TO be allocated before calling this function
return
-
this
->
eval_on_single_input
(
input
,
output
);
return
-
this
->
eval_on_single_input
(
input
,
output
,
parameters
);
}
void
MSE
::
calculate_residual_gradient
(
std
::
vector
<
double
>*
input
,
...
...
@@ -397,11 +399,11 @@ namespace lib4neuro {
if
(
delta
!=
0
)
{
/* Computation of f_val1 = f(x + delta) */
parameters
->
at
(
i
)
=
former_parameter_value
+
delta
;
f_val1
=
-
1
*
this
->
eval_on_single_input
(
input
,
output
,
parameters
);
f_val1
=
this
->
calculate_single_residual
(
input
,
output
,
parameters
);
/* Computation of f_val2 = f(x - delta) */
parameters
->
at
(
i
)
=
former_parameter_value
-
delta
;
f_val2
=
-
1
*
this
->
eval_on_single_input
(
input
,
output
,
parameters
);
f_val2
=
this
->
calculate_single_residual
(
input
,
output
,
parameters
);
gradient
->
at
(
i
)
=
(
f_val1
-
f_val2
)
/
(
2
*
delta
);
}
...
...
This diff is collapsed.
Click to expand it.
src/ErrorFunction/ErrorFunctions.h
+
4
−
2
View file @
6389037f
...
...
@@ -183,7 +183,8 @@ class ErrorFunctionDifferentiable : public ErrorFunction {
double
h
=
1e-3
)
=
0
;
virtual
double
calculate_single_residual
(
std
::
vector
<
double
>*
input
,
std
::
vector
<
double
>*
output
)
=
0
;
std
::
vector
<
double
>*
output
,
std
::
vector
<
double
>*
parameters
=
nullptr
)
=
0
;
};
class
MSE
:
public
ErrorFunctionDifferentiable
{
...
...
@@ -226,7 +227,8 @@ class ErrorFunctionDifferentiable : public ErrorFunction {
* @return
*/
virtual
double
calculate_single_residual
(
std
::
vector
<
double
>*
input
,
std
::
vector
<
double
>*
output
)
override
;
std
::
vector
<
double
>*
output
,
std
::
vector
<
double
>*
parameters
)
override
;
/**
* Compute gradient of the residual function f(x) = 0 - MSE(x) for a specific input x.
...
...
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