We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ab2aafd commit eb49369Copy full SHA for eb49369
beginner_source/examples_autograd/polynomial_autograd.py
@@ -67,9 +67,12 @@
67
d -= learning_rate * d.grad
68
69
# Manually zero the gradients after updating weights
70
- a.grad = None
71
- b.grad = None
72
- c.grad = None
73
- d.grad = None
+ # by using machine epsilon for standard float (64-bit)
+ import sys
+
+ a.grad = loss*sys.float_info.epsilon
74
+ b.grad = loss*sys.float_info.epsilon
75
+ c.grad = loss*sys.float_info.epsilon
76
+ d.grad = loss*sys.float_info.epsilon
77
78
print(f'Result: y = {a.item()} + {b.item()} x + {c.item()} x^2 + {d.item()} x^3')
0 commit comments