Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
c38d7e55
Commit
c38d7e55
authored
Feb 13, 2018
by
Davis King
Browse files
Refactored the random feature selection function so that it always has bounded
runtime, even with very bad parameter selections.
parent
ef4b7a0e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
dlib/image_processing/shape_predictor_trainer.h
dlib/image_processing/shape_predictor_trainer.h
+9
-6
No files found.
dlib/image_processing/shape_predictor_trainer.h
View file @
c38d7e55
...
@@ -523,15 +523,18 @@ namespace dlib
...
@@ -523,15 +523,18 @@ namespace dlib
{
{
const
double
lambda
=
get_lambda
();
const
double
lambda
=
get_lambda
();
impl
::
split_feature
feat
;
impl
::
split_feature
feat
;
double
accept_prob
;
const
size_t
max_iters
=
get_feature_pool_size
()
*
get_feature_pool_size
()
;
do
for
(
size_t
i
=
0
;
i
<
max_iters
;
++
i
)
{
{
feat
.
idx1
=
rnd
.
get_random_32bit_number
()
%
get_feature_pool_size
();
feat
.
idx1
=
rnd
.
get_integer
(
get_feature_pool_size
());
feat
.
idx2
=
rnd
.
get_random_32bit_number
()
%
get_feature_pool_size
();
feat
.
idx2
=
rnd
.
get_integer
(
get_feature_pool_size
());
while
(
feat
.
idx1
==
feat
.
idx2
)
feat
.
idx2
=
rnd
.
get_integer
(
get_feature_pool_size
());
const
double
dist
=
length
(
pixel_coordinates
[
feat
.
idx1
]
-
pixel_coordinates
[
feat
.
idx2
]);
const
double
dist
=
length
(
pixel_coordinates
[
feat
.
idx1
]
-
pixel_coordinates
[
feat
.
idx2
]);
accept_prob
=
std
::
exp
(
-
dist
/
lambda
);
const
double
accept_prob
=
std
::
exp
(
-
dist
/
lambda
);
if
(
accept_prob
>
rnd
.
get_random_double
())
break
;
}
}
while
(
feat
.
idx1
==
feat
.
idx2
||
!
(
accept_prob
>
rnd
.
get_random_double
()));
feat
.
thresh
=
(
rnd
.
get_random_double
()
*
256
-
128
)
/
2.0
;
feat
.
thresh
=
(
rnd
.
get_random_double
()
*
256
-
128
)
/
2.0
;
...
...
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