Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gradient checks do not match #13

Open
vuptran opened this issue Jul 8, 2017 · 2 comments
Open

gradient checks do not match #13

vuptran opened this issue Jul 8, 2017 · 2 comments

Comments

@vuptran
Copy link

vuptran commented Jul 8, 2017

I checked the gradients you derived against the numerical gradients, and your implementation does not match. It looks like the error is in two places:

  1. In calculate_loss, you average the total loss (including the regularization term) over the data batch. The correct implementation should average only the log loss, but not the regularization term.

  2. In build_model, the gradients (dW1, dW2, db1, db2) during backprop should be averaged over the data batch. Again, the correct implementation should not include the regularization terms in the average over the data batch.

@uripeled2
Copy link

Do you have or know a better implementation?
Can you explain or show to me how you checked it?

@vuptran
Copy link
Author

vuptran commented May 11, 2020

@uripeled2 I have a method for gradient checking in my implementation here: https://github.com/vuptran/introduction-to-neural-networks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants