Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
faust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Admin message
GitLab upgrade completed. Current version is 17.11.4.
Show more breadcrumbs
faust group
faust
Commits
16956364
Commit
16956364
authored
2 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Add the epsilon on error change for Faust::StoppingCriterion.
parent
6e77e55f
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/algorithm/factorization/faust_StoppingCriterion.h
+16
-5
16 additions, 5 deletions
src/algorithm/factorization/faust_StoppingCriterion.h
src/algorithm/factorization/faust_StoppingCriterion.hpp
+21
-4
21 additions, 4 deletions
src/algorithm/factorization/faust_StoppingCriterion.hpp
with
37 additions
and
9 deletions
src/algorithm/factorization/faust_StoppingCriterion.h
+
16
−
5
View file @
16956364
...
...
@@ -52,19 +52,21 @@ namespace Faust
class
StoppingCriterion
{
public:
StoppingCriterion
()
:
isCriterionError
(
false
),
nb_it
(
500
){}
StoppingCriterion
()
:
isCriterionError
(
false
),
nb_it
(
500
),
epsErr
(
-
1
),
lastErr
(
-
1
){}
StoppingCriterion
(
int
nb_it_
)
:
isCriterionError
(
false
),
nb_it
(
nb_it_
){
check_validity
();}
StoppingCriterion
(
T
errorThreshold_
,
int
maxIteration_
=
10000
)
:
isCriterionError
(
true
),
errorThreshold
(
errorThreshold_
),
maxIteration
(
maxIteration_
){
check_validity
();}
isCriterionError
(
true
),
errorThreshold
(
errorThreshold_
),
maxIteration
(
maxIteration_
)
,
epsErr
(
-
1
),
lastErr
(
-
1
)
{
check_validity
();}
StoppingCriterion
(
bool
isCriterionError_
);
StoppingCriterion
(
int
nb_it
,
bool
isCriterionError
,
T
errorThreshold
,
int
maxIteration
=
10000
);
StoppingCriterion
(
int
nb_it
,
bool
isCriterionError
,
T
errorThreshold
,
int
maxIteration
=
10000
,
T
epsErr
=-
1
);
~
StoppingCriterion
(){}
...
...
@@ -72,6 +74,13 @@ namespace Faust
bool
do_continue
(
int
current_ite
,
T
error
=-
2.0
)
const
;
int
get_crit
()
const
{
return
nb_it
;}
bool
isCriterionErr
()
const
{
return
isCriterionError
;}
bool
isCriterionEpsErr
()
const
{
return
epsErr
>
-
1
;}
/**
* Set the epsilon error.
*
* This function also reinitializes lastErr so the same StoppingCriterion can be reused on multiple algorithm executions.
*/
void
setCriterionEpsErr
(
const
T
&
epsErr
)
{
this
->
epsErr
=
epsErr
;
lastErr
=
-
1
;}
void
Display
()
const
;
string
to_string
()
const
;
static
const
T
NO_ERROR_PASSED
;
...
...
@@ -83,6 +92,8 @@ namespace Faust
bool
isCriterionError
;
int
nb_it
;
// number of iterations if !isCriterionError
T
errorThreshold
;
T
epsErr
;
T
lastErr
;
int
maxIteration
;
// only used as stopping criterion, if isCriterionError, when error is still greater than
static
const
char
*
m_className
;
...
...
This diff is collapsed.
Click to expand it.
src/algorithm/factorization/faust_StoppingCriterion.hpp
+
21
−
4
View file @
16956364
...
...
@@ -52,7 +52,7 @@ template<typename T>
const
char
*
Faust
::
StoppingCriterion
<
T
>::
m_className
=
"Faust::StoppingCriterion::"
;
template
<
typename
T
>
Faust
::
StoppingCriterion
<
T
>::
StoppingCriterion
(
bool
isCriterionError_
)
:
isCriterionError
(
isCriterionError_
)
Faust
::
StoppingCriterion
<
T
>::
StoppingCriterion
(
bool
isCriterionError_
)
:
isCriterionError
(
isCriterionError_
)
,
epsErr
(
-
1
)
{
if
(
isCriterionError_
)
{
...
...
@@ -64,8 +64,8 @@ Faust::StoppingCriterion<T>::StoppingCriterion(bool isCriterionError_) : isCrite
}
template
<
typename
T
>
Faust
::
StoppingCriterion
<
T
>::
StoppingCriterion
(
int
nb_it
,
bool
isCriterionError
,
T
errorThreshold
,
int
maxIteration
/* default 10000 */
)
:
isCriterionError
(
isCriterionError
),
nb_it
(
nb_it
),
errorThreshold
(
errorThreshold
),
maxIteration
(
maxIteration
)
Faust
::
StoppingCriterion
<
T
>::
StoppingCriterion
(
int
nb_it
,
bool
isCriterionError
,
T
errorThreshold
,
int
maxIteration
/* default 10000
*/
,
T
epsErr
/*=-1
*/
)
:
isCriterionError
(
isCriterionError
),
nb_it
(
nb_it
),
errorThreshold
(
errorThreshold
),
maxIteration
(
maxIteration
)
,
epsErr
(
epsErr
),
lastErr
(
-
1
)
{
check_validity
();
}
...
...
@@ -95,8 +95,25 @@ template<typename T>
bool
Faust
::
StoppingCriterion
<
T
>::
do_continue
(
int
current_ite
,
T
current_error
/* = NO_ERROR_PASSED */
)
const
{
if
(
epsErr
>
-
1
)
{
// the stopping criterion compares the error delta between two calls
if
(
lastErr
>
-
1
)
{
// it is not the first time the function is call (not the first iteration of the algorithm behind)
auto
edelta
=
lastErr
-
current_error
;
if
(
edelta
<
epsErr
)
{
std
::
cout
<<
"error delta between last two iterations "
<<
edelta
<<
" < "
<<
epsErr
<<
" the algorithm should stop."
<<
std
::
endl
;
return
false
;
}
}
const_cast
<
Faust
::
StoppingCriterion
<
T
>*>
(
this
)
->
lastErr
=
current_error
;
// harmless
}
if
(
!
isCriterionError
)
// if criterion is number of iteration, current_error does not matter
return
current_ite
<
nb_it
?
true
:
false
;
return
current_ite
<
nb_it
;
else
if
(
isCriterionError
&&
current_error
>=
0
)
if
(
current_error
<
errorThreshold
)
return
false
;
...
...
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