From 7e8c3cd01464132d026fac910e9f39ad4ef97e60 Mon Sep 17 00:00:00 2001 From: Andrej Karpathy Date: Sun, 12 Apr 2020 21:56:36 -0700 Subject: [PATCH] fix typo in neuron call from back when i was debugging, use generator there is no need to construct a list here --- micrograd/nn.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/micrograd/nn.py b/micrograd/nn.py index 15ef37a1..30d5d777 100644 --- a/micrograd/nn.py +++ b/micrograd/nn.py @@ -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): @@ -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):