Skip to content

Commit

Permalink
fix typo in neuron call from back when i was debugging, use generator…
Browse files Browse the repository at this point in the history
… there is no need to construct a list here
  • Loading branch information
karpathy committed Apr 13, 2020
1 parent 075677b commit 7e8c3cd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion micrograd/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
from micrograd.engine import Value

class Module:

def zero_grad(self):
for p in self.parameters():
p.grad = 0

def parameters(self):
return []

class Neuron(Module):

def __init__(self, nin, nonlin=True):
Expand All @@ -14,7 +18,7 @@ def __init__(self, nin, nonlin=True):
self.nonlin = nonlin

def __call__(self, x):
act = sum([wi*xi for wi,xi in zip(self.w, x)], self.b)
act = sum((wi*xi for wi,xi in zip(self.w, x)), self.b)
return act.relu() if self.nonlin else act

def parameters(self):
Expand Down

0 comments on commit 7e8c3cd

Please sign in to comment.