Commit 6ed74b7a authored by Davis King's avatar Davis King

Simplified the code a little.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403522
parent 48389c5a
...@@ -111,9 +111,6 @@ namespace dlib ...@@ -111,9 +111,6 @@ namespace dlib
// Compute f'(alpha) (i.e. the gradient of f(alpha)) for the current alpha. // Compute f'(alpha) (i.e. the gradient of f(alpha)) for the current alpha.
matrix<T,NR,NC,MM,L> df = Q*alpha - b; matrix<T,NR,NC,MM,L> df = Q*alpha - b;
// This variable should always contain the current value of trans(alpha)*df
T alpha_df = trans(alpha)*df;
const T tau = 1000*std::numeric_limits<T>::epsilon(); const T tau = 1000*std::numeric_limits<T>::epsilon();
T big, little; T big, little;
...@@ -153,7 +150,7 @@ namespace dlib ...@@ -153,7 +150,7 @@ namespace dlib
// greater than or equal to the distance to the optimum solution so it is a // greater than or equal to the distance to the optimum solution so it is a
// good way to decide if we should stop. See the book referenced above for // good way to decide if we should stop. See the book referenced above for
// more information. In particular, see the part about the Wolfe Dual. // more information. In particular, see the part about the Wolfe Dual.
if (alpha_df - C*little < eps) if (trans(alpha)*df - C*little < eps)
break; break;
...@@ -187,8 +184,6 @@ namespace dlib ...@@ -187,8 +184,6 @@ namespace dlib
// avoid the buildup of numerical errors you get with the alternate update // avoid the buildup of numerical errors you get with the alternate update
// below. // below.
df = Q*alpha - b; df = Q*alpha - b;
alpha_df = trans(alpha)*df;
} }
else else
{ {
...@@ -196,16 +191,8 @@ namespace dlib ...@@ -196,16 +191,8 @@ namespace dlib
const T delta_alpha_big = alpha(big_idx) - old_alpha_big; const T delta_alpha_big = alpha(big_idx) - old_alpha_big;
const T delta_alpha_little = alpha(little_idx) - old_alpha_little; const T delta_alpha_little = alpha(little_idx) - old_alpha_little;
alpha_df += delta_alpha_big*df(big_idx) + delta_alpha_little*df(little_idx);
for(long k = 0; k < df.nr(); ++k) for(long k = 0; k < df.nr(); ++k)
{ df(k) += Q(big_idx,k)*delta_alpha_big + Q(little_idx,k)*delta_alpha_little;;
T temp = Q(big_idx,k)*delta_alpha_big + Q(little_idx,k)*delta_alpha_little;
df(k) += temp;
alpha_df += alpha(k)*temp;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment