提交 8bad060c authored 作者: David Warde-Farley's avatar David Warde-Farley

Make tutorials/docs PEP 3113 compliant (remove tuple parameter unpacking).

上级 8ff2fb82
...@@ -160,13 +160,17 @@ version that it produces in the code I gave above. ...@@ -160,13 +160,17 @@ version that it produces in the code I gave above.
raise TypeError('%s only works on doubles' % self.name) raise TypeError('%s only works on doubles' % self.name)
return gof.Apply(self, [x, y], [double()]) return gof.Apply(self, [x, y], [double()])
def perform(self, node, (x, y), (z, )): def perform(self, node, inp, out):
x, y = inp
z, = out
z[0] = self.fn(x, y) z[0] = self.fn(x, y)
def __str__(self): def __str__(self):
return self.name return self.name
def c_code(self, node, name, (x, y), (z, ), sub): def c_code(self, node, name, inp, out, sub):
x, y = inp
z, = out
return self.ccode % locals() return self.ccode % locals()
......
...@@ -363,7 +363,9 @@ arithmetic operators: ...@@ -363,7 +363,9 @@ arithmetic operators:
raise TypeError('%s only works on doubles' % self.name) raise TypeError('%s only works on doubles' % self.name)
return gof.Apply(self, [x, y], [double()]) return gof.Apply(self, [x, y], [double()])
def perform(self, node, (x, y), (z, )): def perform(self, node, inp, out):
x, y = inp
z, = out
z[0] = self.fn(x, y) z[0] = self.fn(x, y)
def __str__(self): def __str__(self):
......
...@@ -89,9 +89,13 @@ write an Op:** ...@@ -89,9 +89,13 @@ write an Op:**
return x * numpy.log(x) return x * numpy.log(x)
def impl(self, x): def impl(self, x):
return XlogX.st_impl(x) return XlogX.st_impl(x)
def grad(self, (x,), (gz,)): def grad(self, inp, grads):
x, = inp
gz, = grads
return [gz * (1 + scalar.log(x))] return [gz * (1 + scalar.log(x))]
def c_code(self, node, name, (x,), (z,), sub): def c_code(self, node, name, inp, out, sub):
x, = inp
z, = out
if node.inputs[0].type in [scalar.float32, scalar.float64]: if node.inputs[0].type in [scalar.float32, scalar.float64]:
return """%(z)s = return """%(z)s =
%(x)s == 0.0 %(x)s == 0.0
......
...@@ -133,7 +133,8 @@ matrix ``W`` and a bias ``b``, you can define: ...@@ -133,7 +133,8 @@ matrix ``W`` and a bias ``b``, you can define:
def __getstate__(self): def __getstate__(self):
return (W, b) return (W, b)
def __setstate__(self, (W,b)): def __setstate__(self, state):
W, b = state
self.W = W self.W = W
self.b = b self.b = b
...@@ -146,7 +147,8 @@ functions to reflect the change in name: ...@@ -146,7 +147,8 @@ functions to reflect the change in name:
def __getstate__(self): def __getstate__(self):
return (weights, bias) return (weights, bias)
def __setstate__(self, (W,b)): def __setstate__(self, state):
W, b = state
self.weights = W self.weights = W
self.bias = b self.bias = b
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论