提交 77c20a3b authored 作者: David Warde-Farley's avatar David Warde-Farley

Another whitespace cleanup.

上级 8bad060c
......@@ -36,7 +36,7 @@ class BROKEN_ON_PURPOSE_Add(gof.Op):
#ERROR TO ADD THIS CRAPPY OFFSET
if self.py_offset:
out[0] = z+0.5
else: out[0] = z
else: out[0] = z
def c_code(self, node, name, (a, b), (z,), sub):
return """
......@@ -75,7 +75,7 @@ class BROKEN_ON_PURPOSE_Add(gof.Op):
# inconsistent is a invalid op, whose perform and c_code do not match
inconsistent = BROKEN_ON_PURPOSE_Add(False)
# off_by_half is a good op, that is different from theano.sparse.sd_csc
off_by_half = BROKEN_ON_PURPOSE_Add(True)
off_by_half = BROKEN_ON_PURPOSE_Add(True)
class WeirdBrokenOp(gof.Op):
"""
......@@ -172,11 +172,11 @@ def test_badclinkeroutput():
a = theano.tensor.dvector()
b = theano.tensor.dvector()
f_good = theano.function([a, b],
off_by_half(a, b),
f_good = theano.function([a, b],
off_by_half(a, b),
mode=debugmode.DebugMode(check_c_code=True))
f_inconsistent = theano.function([a,b],
inconsistent(a, b),
f_inconsistent = theano.function([a,b],
inconsistent(a, b),
mode=debugmode.DebugMode(check_c_code=True))
#this should evaluate with no error
......@@ -189,7 +189,7 @@ def test_badclinkeroutput():
return #TEST PASS
assert False #an error should have been detected
def test_badoptimization():
@gof.local_optimizer([theano.tensor.add])
......@@ -204,7 +204,7 @@ def test_badoptimization():
a = theano.tensor.dvector()
b = theano.tensor.dvector()
f = theano.function([a, b], a+b,
f = theano.function([a, b], a+b,
mode=debugmode.DebugMode(optimizer=opt, check_c_code=True))
try:
......@@ -235,8 +235,8 @@ def test_stochasticoptimization():
b = theano.tensor.dvector()
try:
f = theano.function([a, b],
theano.tensor.add(a, b),
f = theano.function([a, b],
theano.tensor.add(a, b),
mode=debugmode.DebugMode(optimizer=opt, check_c_code=True))
except debugmode.StochasticOrder:
return #TEST PASS
......
......@@ -73,7 +73,7 @@ class TanhRnn(Op):
This class implements the recurrent part of a recurrent neural network.
There is not a neat way to include this in a more fine-grained way in Theano at the moment,
so to get something working, I'm implementing a relatively complicated Op that could be
so to get something working, I'm implementing a relatively complicated Op that could be
broken down later into constituents.
Anyway, this Op implements recursive computation of the form:
......@@ -81,7 +81,7 @@ class TanhRnn(Op):
.. latex-eqn:
z_t &= \tanh( z_{t-1} A + x_{t-1})
For z0 a vector, and x a TxM matrix, it returns a matrix z of shape (T+1, M),
For z0 a vector, and x a TxM matrix, it returns a matrix z of shape (T+1, M),
in which z[0] = z0.
"""
......@@ -275,7 +275,7 @@ def test_WEIRD_STUFF():
print rnn1.minimizer.step.maker.inputs
print rnn2.minimizer.step.maker.inputs
# for i in range(1,len(rnn1.minimizer.step.maker.inputs)):
# print "valid update:",theano.printing.pp(rnn1.minimizer.step.maker.inputs[i].update),
......@@ -284,7 +284,7 @@ def test_WEIRD_STUFF():
# print rnn2.minimizer.step.maker.inputs[i].update.name
# print dir(rnn1.minimizer.step.maker.inputs[5].update)
# print dir(rnn2.minimizer.step.maker.inputs[5].update)
niter=3
......
......@@ -24,7 +24,7 @@ class TDouble(Type):
return """
%(name)s = 0;
%(name)s_bad_thing = malloc(100000);
//printf("Initializing %(name)s\\n");
//printf("Initializing %(name)s\\n");
""" % locals()
def c_literal(self, data):
......@@ -40,7 +40,7 @@ class TDouble(Type):
%(name)s_bad_thing = NULL;
//printf("Extracting %(name)s\\n");
""" % dict(locals(), **sub)
def c_sync(self, name, sub):
return """
Py_XDECREF(py_%(name)s);
......@@ -71,7 +71,7 @@ class MyOp(Op):
def __init__(self, nin, name):
self.nin = nin
self.name = name
def make_node(self, *inputs):
assert len(inputs) == self.nin
inputs = map(as_variable, inputs)
......@@ -98,28 +98,28 @@ class Binary(MyOp):
def __init__(self):
MyOp.__init__(self, 2, self.__class__.__name__)
class Add(Binary):
def c_code(self, node, name, (x, y), (z, ), sub):
return "%(z)s = %(x)s + %(y)s;" % locals()
def impl(self, x, y):
return x + y
add = Add()
class Sub(Binary):
def c_code(self, node, name, (x, y), (z, ), sub):
return "%(z)s = %(x)s - %(y)s;" % locals()
def impl(self, x, y):
return -10 # erroneous (most of the time)
sub = Sub()
class Mul(Binary):
def c_code(self, node, name, (x, y), (z, ), sub):
return "%(z)s = %(x)s * %(y)s;" % locals()
def impl(self, x, y):
return x * y
mul = Mul()
class Div(Binary):
def c_code(self, node, name, (x, y), (z, ), sub):
return "%(z)s = %(x)s / %(y)s;" % locals()
......@@ -185,7 +185,7 @@ def test_clinker_dups_inner():
lnk = CLinker().accept(Env([x, y, z], [e]))
fn = lnk.make_function()
assert fn(1.0, 2.0, 3.0) == 8.0
######################
......@@ -254,7 +254,7 @@ def test_duallinker_mismatch():
################################
# Test that failure code works #
################################
class AddFail(Binary):
def c_code(self, node, name, (x, y), (z, ), sub):
fail=sub['fail']
......
......@@ -32,7 +32,7 @@ class MyOp(Op):
self.name = name
if impl:
self.impl = impl
def make_node(self, *inputs):
assert len(inputs) == self.nin
inputs = map(as_variable, inputs)
......@@ -85,7 +85,7 @@ class TestPerformLinker:
i[1].data = 2
fn()
assert o[0].data == 1.5
def test_function(self):
x, y, z = inputs()
e = mul(add(x, y), div(x, y))
......@@ -130,7 +130,7 @@ class TestWrapLinker:
nodes = []
def wrap(i, node, th):
nodes.append(node.op)
x, y, z = inputs()
e = mul(add(x, y), div(x, y))
fn, i, o = wrap_linker(Env([x, y, z], [e]), [PerformLinker(allow_gc=False)], wrap).make_thunk()
......@@ -154,8 +154,8 @@ class TestWrapLinker:
fn()
assert nodes == [div, add, mul]
assert o[0].data == 1.5
......@@ -15,7 +15,7 @@ def _grad_sources_inputs(*args):
return grad_sources_inputs(warn_type=False, *args)
class test_grad_sources_inputs(unittest.TestCase):
def test_retNone1(self):
def test_retNone1(self):
"""Test that it is not ok to return None from op.grad()"""
class retNone(gof.op.Op):
def make_node(self):
......@@ -31,7 +31,7 @@ class test_grad_sources_inputs(unittest.TestCase):
self.failUnless(e[0] is gradient._msg_retType)
return
self.fail()
def test_retNone1_b(self):
def test_retNone1_b(self):
"""Test that it is ok to return [None] from op.grad()"""
class retNone(gof.op.Op):
def make_node(self, *inputs):
......@@ -44,7 +44,7 @@ class test_grad_sources_inputs(unittest.TestCase):
g = _grad_sources_inputs([(a.out, 1)], None)
self.failUnless(not i in g)
def test_wrong_rval_len1(self):
def test_wrong_rval_len1(self):
"""Test that it is not ok to return the wrong number of gradients"""
class retNone(gof.op.Op):
def make_node(self, *inputs):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论