This commit is contained in:
Carl Pearson
2016-11-16 12:01:12 -06:00
parent ff81047809
commit 387ee49c76

View File

@@ -94,8 +94,8 @@ class Model(object):
def dLdb2(self, x, y): def dLdb2(self, x, y):
return self.dLdf(x, y) * self.dfdb2() return self.dLdf(x, y) * self.dfdb2()
def dfdw2(self, x): def dfdw2(self, x): # how each entry of f changes wrt each entry of w2
return np.sum(self.a(x)) return self.a(x)
def dfda(self): # how f changes with ith element of a def dfda(self): # how f changes with ith element of a
return self.w2 return self.w2
@@ -106,10 +106,10 @@ class Model(object):
def dLdz1(self, x, y): def dLdz1(self, x, y):
"""Compute dL/dz1 for an input x and expected output y""" """Compute dL/dz1 for an input x and expected output y"""
return self.dLdf(x, y) * np.sum(self.dfda() * self.dadz1(x)) return self.dLdf(x, y) * np.dot(self.dfda(), self.dadz1(x))
def dz1dw1(self, x): def dz1dw1(self, x):
return x return x * self.w1
def dLdw1(self, x, y): def dLdw1(self, x, y):
"""Compute dL/dw1 for an input x and expected output y""" """Compute dL/dw1 for an input x and expected output y"""