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
7e9013f4
Commit
7e9013f4
authored
Jun 13, 2015
by
Davis King
Browse files
Made pick_initial_centers() slightly more robust.
parent
2d57a754
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
dlib/svm/kkmeans.h
dlib/svm/kkmeans.h
+2
-2
No files found.
dlib/svm/kkmeans.h
View file @
7e9013f4
...
...
@@ -288,7 +288,7 @@ namespace dlib
struct
dlib_pick_initial_centers_data
{
dlib_pick_initial_centers_data
()
:
idx
(
0
),
dist
(
1e200
){}
dlib_pick_initial_centers_data
()
:
idx
(
0
),
dist
(
std
::
numeric_limits
<
double
>::
infinity
()
){}
long
idx
;
double
dist
;
bool
operator
<
(
const
dlib_pick_initial_centers_data
&
d
)
const
{
return
dist
<
d
.
dist
;
}
...
...
@@ -331,7 +331,7 @@ namespace dlib
// pick the first sample as one of the centers
centers
.
push_back
(
samples
[
0
]);
const
long
best_idx
=
static_cast
<
long
>
(
samples
.
size
()
-
samples
.
size
()
*
percentile
-
1
);
const
long
best_idx
=
static_cast
<
long
>
(
std
::
max
(
0.0
,
samples
.
size
()
-
samples
.
size
()
*
percentile
-
1
)
)
;
// pick the next center
for
(
long
i
=
0
;
i
<
num_centers
-
1
;
++
i
)
...
...
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