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
1c503219
Commit
1c503219
authored
Jul 07, 2013
by
Davis King
Browse files
Improved svm struct interface a little more. Fixed a bug and added
non-negative weight learning support.
parent
cc9ff97a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
tools/python/src/svm_struct.cpp
tools/python/src/svm_struct.cpp
+8
-2
No files found.
tools/python/src/svm_struct.cpp
View file @
1c503219
...
@@ -88,13 +88,15 @@ matrix<double,0,1> solve_structural_svm_problem(
...
@@ -88,13 +88,15 @@ matrix<double,0,1> solve_structural_svm_problem(
const
bool
be_verbose
=
hasattr
(
problem
,
"be_verbose"
)
&&
extract
<
bool
>
(
problem
.
attr
(
"be_verbose"
));
const
bool
be_verbose
=
hasattr
(
problem
,
"be_verbose"
)
&&
extract
<
bool
>
(
problem
.
attr
(
"be_verbose"
));
const
bool
use_sparse_feature_vectors
=
hasattr
(
problem
,
"use_sparse_feature_vectors"
)
&&
const
bool
use_sparse_feature_vectors
=
hasattr
(
problem
,
"use_sparse_feature_vectors"
)
&&
extract
<
bool
>
(
problem
.
attr
(
"use_sparse_feature_vectors"
));
extract
<
bool
>
(
problem
.
attr
(
"use_sparse_feature_vectors"
));
const
bool
learns_nonnegative_weights
=
hasattr
(
problem
,
"learns_nonnegative_weights"
)
&&
extract
<
bool
>
(
problem
.
attr
(
"learns_nonnegative_weights"
));
double
eps
=
0.001
;
double
eps
=
0.001
;
unsigned
long
max_cache_size
=
10
;
unsigned
long
max_cache_size
=
10
;
if
(
hasattr
(
problem
,
"epsilon"
))
if
(
hasattr
(
problem
,
"epsilon"
))
eps
=
extract
<
double
>
(
problem
.
attr
(
"epsilon"
));
eps
=
extract
<
double
>
(
problem
.
attr
(
"epsilon"
));
if
(
hasattr
(
problem
,
"max_cache_size"
))
if
(
hasattr
(
problem
,
"max_cache_size"
))
eps
=
extract
<
double
>
(
problem
.
attr
(
"max_cache_size"
));
max_cache_size
=
extract
<
double
>
(
problem
.
attr
(
"max_cache_size"
));
const
long
num_samples
=
extract
<
long
>
(
problem
.
attr
(
"num_samples"
));
const
long
num_samples
=
extract
<
long
>
(
problem
.
attr
(
"num_samples"
));
const
long
num_dimensions
=
extract
<
long
>
(
problem
.
attr
(
"num_dimensions"
));
const
long
num_dimensions
=
extract
<
long
>
(
problem
.
attr
(
"num_dimensions"
));
...
@@ -107,6 +109,7 @@ matrix<double,0,1> solve_structural_svm_problem(
...
@@ -107,6 +109,7 @@ matrix<double,0,1> solve_structural_svm_problem(
cout
<<
"num_samples: "
<<
num_samples
<<
endl
;
cout
<<
"num_samples: "
<<
num_samples
<<
endl
;
cout
<<
"num_dimensions: "
<<
num_dimensions
<<
endl
;
cout
<<
"num_dimensions: "
<<
num_dimensions
<<
endl
;
cout
<<
"use_sparse_feature_vectors: "
<<
std
::
boolalpha
<<
use_sparse_feature_vectors
<<
endl
;
cout
<<
"use_sparse_feature_vectors: "
<<
std
::
boolalpha
<<
use_sparse_feature_vectors
<<
endl
;
cout
<<
"learns_nonnegative_weights: "
<<
std
::
boolalpha
<<
learns_nonnegative_weights
<<
endl
;
cout
<<
endl
;
cout
<<
endl
;
}
}
...
@@ -120,6 +123,9 @@ matrix<double,0,1> solve_structural_svm_problem(
...
@@ -120,6 +123,9 @@ matrix<double,0,1> solve_structural_svm_problem(
oca
solver
;
oca
solver
;
matrix
<
double
,
0
,
1
>
w
;
matrix
<
double
,
0
,
1
>
w
;
if
(
learns_nonnegative_weights
)
solver
(
prob
,
w
,
prob
.
get_num_dimensions
());
else
solver
(
prob
,
w
);
solver
(
prob
,
w
);
return
w
;
return
w
;
}
}
...
...
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