ex-7: normalise weights
This commit is contained in:
parent
7daefc590a
commit
1c35bec015
@ -86,6 +86,15 @@ gsl_vector* fisher_proj(sample_t *c1, sample_t *c2) {
|
||||
0, // β = 0
|
||||
w); // vector y
|
||||
|
||||
/* Normalise the weights and force
|
||||
* positiveness for easier
|
||||
* comparison with other methods.
|
||||
*/
|
||||
double norm = gsl_blas_dnrm2(w);
|
||||
if (gsl_vector_isneg(w))
|
||||
norm = -norm;
|
||||
gsl_vector_scale(w, 1/norm);
|
||||
|
||||
// free memory
|
||||
gsl_matrix_free(cov1);
|
||||
gsl_matrix_free(cov2);
|
||||
@ -170,7 +179,7 @@ double fisher_cut(
|
||||
*
|
||||
* with a,b,c given as above.
|
||||
*
|
||||
* */
|
||||
*/
|
||||
double a = var1 - var2;
|
||||
double b = m2*var1 + m1*var2;
|
||||
double c = m2*m2*var1 - m1*m1*var2 + 2*var1*var2 * log(ratio);
|
||||
|
@ -38,7 +38,7 @@ void iterate(
|
||||
gsl_blas_ddot(weight, x, &proj);
|
||||
|
||||
/* Calculate Δ
|
||||
* Note: the step functions θ(x) is computed
|
||||
* Note: the step function θ(x) is computed
|
||||
* by negating the sign bit of the floating
|
||||
* point.
|
||||
*/
|
||||
@ -80,7 +80,15 @@ gsl_vector *percep_train(
|
||||
iterate(signal->data, w, &bias, 1, rate);
|
||||
}
|
||||
|
||||
*cut = -bias;
|
||||
/* Normalise the weights and force
|
||||
* positiveness for easier
|
||||
* comparison with other methods.
|
||||
*/
|
||||
double norm = gsl_blas_dnrm2(w);
|
||||
if (gsl_vector_isneg(w))
|
||||
norm = -norm;
|
||||
gsl_vector_scale(w, 1/norm);
|
||||
*cut = -bias/norm;
|
||||
|
||||
return w;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user