From ed73ea5c8b8e04fef797361a3d80f99b481de9a8 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Mon, 1 Jun 2020 20:33:09 +0000 Subject: [PATCH] ex-7: keep negative sign in perceptron weights --- ex-7/percep.c | 2 -- ex-7/plot.py | 2 +- notes/images/7-percep-proj.pdf | Bin 11599 -> 11036 bytes 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/ex-7/percep.c b/ex-7/percep.c index d762119..df68712 100644 --- a/ex-7/percep.c +++ b/ex-7/percep.c @@ -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; diff --git a/ex-7/plot.py b/ex-7/plot.py index 6151689..42e9f7c 100755 --- a/ex-7/plot.py +++ b/ex-7/plot.py @@ -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) diff --git a/notes/images/7-percep-proj.pdf b/notes/images/7-percep-proj.pdf index 280aee7150c35a59507c5f9bb6eaf02e2415cc4e..059701fbb625a915aeede59295a339171750b9a0 100644 GIT binary patch delta 2709 zcmZuvdpwi-AIBjXaxdiYY;K#d?b-HhE4eJ!T2bb*bU`N9(YBOR$6U%K9G3@?RY<5# zNuwwwUEGgSbdy9#C{a3c$Zx9G>m2s`{`0(F@9*dPdB5ME&+}lr!2NQqB>z5hv#SnS z`R1s{aITJN=gbq87CE;XAJ=B&U|evjT;~VXI61zR^QW`A_~4xM^A*8)C&}CXKBRrF z>!M-g8pmCm%)%xjGx;sf)lnG+4<>3>Y9CnVgMNMe{iQ*n%&Xn=s{I!zRJ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