ex-7: keep negative sign in perceptron weights

This commit is contained in:
Michele Guerini Rocco 2020-06-01 20:33:09 +00:00
parent e3fcd83f37
commit ed73ea5c8b
3 changed files with 1 additions and 3 deletions

View File

@ -85,8 +85,6 @@ gsl_vector *percep_train(
* 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;

View File

@ -25,7 +25,7 @@ scatter(*signal, edgecolor='xkcd:charcoal',
scatter(*noise, edgecolor='xkcd:charcoal',
c='xkcd:pale purple', label='noise')
line(-20*w, 20*w, c='xkcd:midnight blue', label='projection')
line(w-10*v, w+10*v, c='xkcd:scarlet', label='cut')
line(abs(w)-10*v, abs(w)+10*v, c='xkcd:scarlet', label='cut')
xlabel('x')
ylabel('y')
xlim(-1.5, 8)

Binary file not shown.