Skip to content

Commit

Permalink
Optionally use pre-computed topo
Browse files Browse the repository at this point in the history
  • Loading branch information
tekknolagi committed Nov 23, 2024
1 parent dee784c commit d2a2832
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion micrograd/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def build_topo(v):
build_topo(self)
return topo

def backward(self, reverse_topo):
def backward(self, reverse_topo=None):
if reverse_topo is None:
reverse_topo = self.topo()[::-1]
# go one variable at a time and apply the chain rule to get its gradient
self.grad = 1
for v in reverse_topo:
Expand Down

0 comments on commit d2a2832

Please sign in to comment.