tiepvupsu / ebookMLCB

ebook Machine Learning cơ bản
Other
1.33k stars 347 forks source link

12.3. GDM #29

Closed tuanlda78202 closed 2 years ago

tuanlda78202 commented 2 years ago

Chapter 12 GDM, the part I code myself, is different from the result in the book; I checked the code of Mr Tiep also encountered the same situation. Then I detect; specifically, it is the one that initially creates the y value: we use the np.random.random(1000) function, we will return an array with shape (1000,) if we do not notice y.reshape(-1, 1) to match matrix addition and subtraction operations, it will be confusing (because py is different in size, it will treat it as broadcasting). Yes, grad will return a vector, but it returns a matrix because of the confusion above. That leads to consequences; later on, the code does not run correctly. Source code fix : https://bit.ly/3mFp8N1 or https://bit.ly/3iOXImD

244433855_2846991418944200_9069998415242239147_n 244355556_2846990928944249_1399441177654916885_n

tiepvupsu commented 2 years ago

Cảm ơn bạn đã báo lỗi. Mình cũng chưa hiểu rõ phải sửa chỗ nào. Bạn có thể tạo PR giúp mình vào file này được không? Cảm ơn bạn.

tuanlda78202 commented 2 years ago

Em thật sự cũng chưa biết tạo PR kiểu gì cả ạ nhưng mà nó nằm ở dòng 399 ở cái file anh gửi, chỗ y phải sửa thành y.reshape(-1,1) ạ

image
tiepvupsu commented 2 years ago

Mình đã fix ở commit này https://github.com/tiepvupsu/ebookMLCB/commit/c77574c23093ae020f4ad2abcd6675a10e1a8c17 nhé. Mình đổi lại cho giống trên web. Cảm ơn bạn đã đóng góp.