rasbt / machine-learning-book

Code Repository for Machine Learning with PyTorch and Scikit-Learn
https://sebastianraschka.com/books/#machine-learning-with-pytorch-and-scikit-learn
MIT License
3.64k stars 1.31k forks source link

Chapter 2 Negative Gradient #141

Closed SPDA36 closed 1 year ago

SPDA36 commented 1 year ago

Page 38 says we update weights and biases by adding the parameter to the negative gradient learning rate. However, in the Adaline code sections, pages 40 and 49, no negative gradient is used. For example, page 49, `self.w_ += self.eta 2.0 xi (error)`.

rasbt commented 1 year ago

Thanks for the note, and that's a good point. At first glance it may look wrong. But we have errors = (y - output), and that's the negative gradient.

That's because -(y - output) is the gradient as shown at the bottom of pg 38. And -1 * -(y - output) simplifies to (y - output).

Screenshot 2023-08-17 at 11 59 26 AM
SPDA36 commented 1 year ago

The obvious was staring at me and I still managed to overlook it. Thanks for the clarification!