Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
14dbd96b
Commit
14dbd96b
authored
Oct 28, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a bug in find_max_factor_graph_viterbi() which occurred when a
zero order model had negative factor values.
parent
d3393766
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
7 deletions
+35
-7
find_max_factor_graph_viterbi.h
dlib/optimization/find_max_factor_graph_viterbi.h
+1
-1
find_max_factor_graph_viterbi.cpp
dlib/test/find_max_factor_graph_viterbi.cpp
+34
-6
No files found.
dlib/optimization/find_max_factor_graph_viterbi.h
View file @
14dbd96b
...
...
@@ -92,7 +92,7 @@ namespace dlib
{
matrix
<
unsigned
long
,
1
,
1
>
node_state
;
unsigned
long
best_state
=
0
;
double
best_val
=
0
;
double
best_val
=
-
std
::
numeric_limits
<
double
>::
infinity
()
;
for
(
unsigned
long
s
=
0
;
s
<
num_states
;
++
s
)
{
node_state
(
0
)
=
s
;
...
...
dlib/test/find_max_factor_graph_viterbi.cpp
View file @
14dbd96b
...
...
@@ -26,7 +26,8 @@ namespace
template
<
unsigned
long
O
,
unsigned
long
NS
,
unsigned
long
num_nodes
unsigned
long
num_nodes
,
bool
all_negative
>
class
map_problem
{
...
...
@@ -37,6 +38,8 @@ namespace
map_problem
()
{
data
=
randm
(
number_of_nodes
(),(
long
)
std
::
pow
(
num_states
(),(
double
)
order
()
+
1
),
rnd
);
if
(
all_negative
)
data
=
-
data
;
}
unsigned
long
number_of_nodes
(
...
...
@@ -110,18 +113,20 @@ namespace
template
<
unsigned
long
order
,
unsigned
long
num_states
,
unsigned
long
num_nodes
unsigned
long
num_nodes
,
bool
all_negative
>
void
do_test
()
void
do_test
_
()
{
dlog
<<
LINFO
<<
"order: "
<<
order
<<
" num_states: "
<<
num_states
<<
" num_nodes: "
<<
num_nodes
;
<<
" num_states: "
<<
num_states
<<
" num_nodes: "
<<
num_nodes
<<
" all_negative: "
<<
all_negative
;
for
(
int
i
=
0
;
i
<
25
;
++
i
)
{
print_spinner
();
map_problem
<
order
,
num_states
,
num_nodes
>
prob
;
map_problem
<
order
,
num_states
,
num_nodes
,
all_negative
>
prob
;
std
::
vector
<
unsigned
long
>
assign
,
assign2
;
brute_force_find_max_factor_graph_viterbi
(
prob
,
assign
);
find_max_factor_graph_viterbi
(
prob
,
assign2
);
...
...
@@ -133,6 +138,26 @@ namespace
}
}
template
<
unsigned
long
order
,
unsigned
long
num_states
,
unsigned
long
num_nodes
>
void
do_test
()
{
do_test_
<
order
,
num_states
,
num_nodes
,
false
>
();
}
template
<
unsigned
long
order
,
unsigned
long
num_states
,
unsigned
long
num_nodes
>
void
do_test_negative
()
{
do_test_
<
order
,
num_states
,
num_nodes
,
true
>
();
}
// ----------------------------------------------------------------------------------------
class
test_find_max_factor_graph_viterbi
:
public
tester
...
...
@@ -151,11 +176,14 @@ namespace
do_test
<
1
,
3
,
1
>
();
do_test
<
1
,
3
,
2
>
();
do_test
<
0
,
3
,
2
>
();
do_test_negative
<
0
,
3
,
2
>
();
do_test
<
1
,
3
,
8
>
();
do_test
<
2
,
3
,
7
>
();
do_test_negative
<
2
,
3
,
7
>
();
do_test
<
3
,
3
,
8
>
();
do_test
<
4
,
3
,
8
>
();
do_test_negative
<
4
,
3
,
8
>
();
do_test
<
0
,
3
,
8
>
();
do_test
<
4
,
3
,
1
>
();
do_test
<
4
,
3
,
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