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
e0532b54
Commit
e0532b54
authored
May 17, 2011
by
Davis King
Browse files
Added some more comments.
parent
ea2a5184
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
dlib/svm/svm_multiclass_linear_trainer.h
dlib/svm/svm_multiclass_linear_trainer.h
+14
-1
No files found.
dlib/svm/svm_multiclass_linear_trainer.h
View file @
e0532b54
...
...
@@ -28,6 +28,15 @@ namespace dlib
WHAT THIS OBJECT REPRESENTS
This object defines the optimization problem for the multiclass SVM trainer
object at the bottom of this file.
The joint feature vectors used by this object, the PSI(x,y) vectors, are
defined as follows:
PSI(x,0) = [x,0,0,0,0, ...,0]
PSI(x,1) = [0,x,0,0,0, ...,0]
PSI(x,2) = [0,0,x,0,0, ...,0]
That is, if there are N labels then the joint feature vector has a
dimension that is N times the dimension of a single x sample. Also,
note that we append a -1 value onto each x to account for the bias term.
!*/
public:
...
...
@@ -81,17 +90,21 @@ namespace dlib
scalar_type
best_val
=
-
std
::
numeric_limits
<
scalar_type
>::
infinity
();
unsigned
long
best_idx
=
0
;
// figure out which label is the best
// Figure out which label is the best. That is, what label maximizes
// LOSS(idx,y) + F(x,y). Note that y in this case is given by distinct_labels[i].
for
(
unsigned
long
i
=
0
;
i
<
distinct_labels
.
size
();
++
i
)
{
using
dlib
::
sparse_vector
::
dot
;
using
dlib
::
dot
;
// Compute the F(x,y) part:
// perform: temp == dot(relevant part of current solution, samples[idx]) - current_bias
scalar_type
temp
=
dot
(
rowm
(
current_solution
,
range
(
i
*
dims
,
(
i
+
1
)
*
dims
-
2
)),
samples
[
idx
])
-
current_solution
((
i
+
1
)
*
dims
-
1
);
// Add the LOSS(idx,y) part:
if
(
labels
[
idx
]
!=
distinct_labels
[
i
])
temp
+=
1
;
// Now temp == LOSS(idx,y) + F(x,y). Check if it is the biggest we have seen.
if
(
temp
>
best_val
)
{
best_val
=
temp
;
...
...
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