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

a question about auto grad. thx #11

Open
yebangyu opened this issue May 20, 2023 · 2 comments
Open

a question about auto grad. thx #11

yebangyu opened this issue May 20, 2023 · 2 comments

Comments

@yebangyu
Copy link

yebangyu commented May 20, 2023

Dear Edward,

From page 21 to page 23, when we are talking about auto grad,

we choose to test conditon ||prev - cur || < epsilon satisfies or not to check whether we have got the minimun

my question is : why not just to test whether the grad of cur is zero or not ?

that is to say :

can

while torch.linalg.norm(x_cur-x_prev) > epsilon:

be replaced by

epsilon = 1e-12 # an enough small value

while abs(cur.grad) > epsilon:

?

thanks a lot !

@EdwardRaff
Copy link
Owner

EdwardRaff commented May 20, 2023 via email

@yebangyu
Copy link
Author

yebangyu commented May 20, 2023

thanks for your reply, Edward

according to the sgd formula:

x_cur = x_prev - learning_rate * grad

if grad is close to zero , we can get that x_cur is approximately equal to x_prev but not vice versa

x_cur is approximately equal to x_prev does not mean that grad is close to zero (maybe just because learning rate is too small)

Am i right ?

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