mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-24 22:38:16 -05:00
huh...this is faster
This commit is contained in:
@@ -30,9 +30,9 @@ class SGD(Optimizer):
|
||||
def step(self) -> None:
|
||||
for i, t in enumerate(self.params):
|
||||
assert t.grad is not None
|
||||
g = t.grad
|
||||
g = t.grad.realize()
|
||||
if self.momentum:
|
||||
self.b[i].assign(self.momentum * self.b[i] + g).realize() # NOTE: self.b[i] is zero on the first run, no if required
|
||||
self.b[i].assign((self.momentum * self.b[i] + g).realize()) # NOTE: self.b[i] is zero on the first run, no if required
|
||||
g = (g + self.momentum * self.b[i]) if self.nesterov else self.b[i]
|
||||
t.assign((t.detach() - g * self.lr).realize())
|
||||
self.realize(self.b)
|
||||
|
||||
Reference in New Issue
Block a user