ex-7: keep negative sign in perceptron weights
This commit is contained in:
parent
e3fcd83f37
commit
ed73ea5c8b
@ -85,8 +85,6 @@ gsl_vector *percep_train(
|
|||||||
* comparison with other methods.
|
* comparison with other methods.
|
||||||
*/
|
*/
|
||||||
double norm = gsl_blas_dnrm2(w);
|
double norm = gsl_blas_dnrm2(w);
|
||||||
if (gsl_vector_isneg(w))
|
|
||||||
norm = -norm;
|
|
||||||
gsl_vector_scale(w, 1/norm);
|
gsl_vector_scale(w, 1/norm);
|
||||||
*cut = -bias/norm;
|
*cut = -bias/norm;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ scatter(*signal, edgecolor='xkcd:charcoal',
|
|||||||
scatter(*noise, edgecolor='xkcd:charcoal',
|
scatter(*noise, edgecolor='xkcd:charcoal',
|
||||||
c='xkcd:pale purple', label='noise')
|
c='xkcd:pale purple', label='noise')
|
||||||
line(-20*w, 20*w, c='xkcd:midnight blue', label='projection')
|
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')
|
xlabel('x')
|
||||||
ylabel('y')
|
ylabel('y')
|
||||||
xlim(-1.5, 8)
|
xlim(-1.5, 8)
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user