Reputation: 717
I am working on neural network and I find that, with *.grad_zero()
I get loss function values properly and also converge to zero. Where, with *.grad_zero
(with out bracket) gives loss function values in 5 digits. (13,564.23). So, what is the difference between them? Why "()" important in FPP. Thank you.
Upvotes: 0
Views: 99
Reputation: 19300
optimizer.zero_grad
is a function, so you need to call it with parentheses. If you don't use the parentheses, you are just referencing the function object but never calling it.
Upvotes: 1