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
f9805be8
"fmoe/git@developer.sourcefind.cn:OpenDAS/fastmoe.git" did not exist on "254cdbbce2361ba39a26186d174849b31e3fb4f2"
Commit
f9805be8
authored
Dec 17, 2012
by
Davis King
Browse files
Fixed a bug which triggered when the last weight was forced to 1.
parent
034eb0ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
1 deletion
+39
-1
dlib/svm/svm_c_linear_dcd_trainer.h
dlib/svm/svm_c_linear_dcd_trainer.h
+39
-1
No files found.
dlib/svm/svm_c_linear_dcd_trainer.h
View file @
f9805be8
...
...
@@ -301,7 +301,7 @@ namespace dlib
for
(
long
i
=
new_idx
;
i
<
x
.
size
();
++
i
)
{
Q
.
push_back
(
dlib
::
dot
(
x
(
i
),
x
(
i
)));
Q
.
push_back
(
length_squared
(
x
(
i
)));
if
(
have_bias
)
{
...
...
@@ -318,6 +318,44 @@ namespace dlib
w
(
dims
-
1
)
=
1
;
}
template
<
typename
T
>
typename
enable_if
<
is_matrix
<
T
>
,
scalar_type
>::
type
length_squared
(
const
T
&
x
)
const
{
if
(
!
last_weight_1
)
{
return
dlib
::
dot
(
x
,
x
);
}
else
{
// skip the last dimension
return
dlib
::
dot
(
colm
(
x
,
0
,
x
.
size
()
-
1
),
colm
(
x
,
0
,
x
.
size
()
-
1
));
}
}
template
<
typename
T
>
typename
disable_if
<
is_matrix
<
T
>
,
scalar_type
>::
type
length_squared
(
const
T
&
x
)
const
{
if
(
!
last_weight_1
)
{
return
dlib
::
dot
(
x
,
x
);
}
else
{
scalar_type
temp
=
0
;
typename
T
::
const_iterator
i
;
for
(
i
=
x
.
begin
();
i
!=
x
.
end
();
++
i
)
{
// skip the last dimension
if
(
static_cast
<
long
>
(
i
->
first
)
<
dims
-
1
)
temp
+=
i
->
second
*
i
->
second
;
}
return
temp
;
}
}
bool
did_init
;
bool
have_bias
;
bool
last_weight_1
;
...
...
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