提交 ce069767 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

PEP8 fixes

上级 83cab8bf
...@@ -135,7 +135,7 @@ class TestScan(unittest.TestCase): ...@@ -135,7 +135,7 @@ class TestScan(unittest.TestCase):
else: else:
shared_outs = [sh * 5 for sh in shared_vars] shared_outs = [sh * 5 for sh in shared_vars]
states_out = [x for x in states_out] states_out = [x for x in states_out]
pure_outs = [ 2 for x in xrange(n_outputs)] pure_outs = [2 for x in xrange(n_outputs)]
return states_out + pure_outs, dict(zip(shared_vars, return states_out + pure_outs, dict(zip(shared_vars,
shared_outs)) shared_outs))
...@@ -220,7 +220,7 @@ class TestScan(unittest.TestCase): ...@@ -220,7 +220,7 @@ class TestScan(unittest.TestCase):
if to_add is not None: if to_add is not None:
shared_values = [sh * 5 + to_add for sh in shared_values] shared_values = [sh * 5 + to_add for sh in shared_values]
for state in nw_states_outs: for state in nw_states_outs:
state[step] += to_add state[step] += to_add
for out in out_mem_buffers: for out in out_mem_buffers:
out[step] = to_add ** 2 out[step] = to_add ** 2
else: else:
...@@ -249,7 +249,7 @@ class TestScan(unittest.TestCase): ...@@ -249,7 +249,7 @@ class TestScan(unittest.TestCase):
if n_steps is not None and abs(n_steps) == 1: if n_steps is not None and abs(n_steps) == 1:
all_nodes = my_f.maker.env.toposort() all_nodes = my_f.maker.env.toposort()
assert len([x for x in all_nodes assert len([x for x in all_nodes
if isinstance(x.op,ScanOp)]) == 0 if isinstance(x.op, ScanOp)]) == 0
print >>sys.stderr, ' n_steps', n_steps print >>sys.stderr, ' n_steps', n_steps
print >>sys.stderr, ' go_backwards', go_backwards print >>sys.stderr, ' go_backwards', go_backwards
...@@ -319,7 +319,8 @@ class TestScan(unittest.TestCase): ...@@ -319,7 +319,8 @@ class TestScan(unittest.TestCase):
if n_steps is not None: if n_steps is not None:
# loose inputs make sense only when n_steps is # loose inputs make sense only when n_steps is
# defined # defined
data = rng.uniform(size=(abs(_n_steps) + offset + pos + 1, 4)) data = rng.uniform(
size=(abs(_n_steps) + offset + pos + 1, 4))
else: else:
data = rng.uniform(size=(abs(_n_steps) + offset, 4)) data = rng.uniform(size=(abs(_n_steps) + offset, 4))
input_values.append(data) input_values.append(data)
...@@ -400,9 +401,9 @@ class TestScan(unittest.TestCase): ...@@ -400,9 +401,9 @@ class TestScan(unittest.TestCase):
[dict(tap=-2, use=True), [dict(tap=-2, use=True),
dict(tap=3, use=True)]] dict(tap=3, use=True)]]
test_nb = 0 test_nb = 0
for n_ins in [1,2]: for n_ins in [1, 2]:
# Randomly pick up 4*n_ins combinations of arguments # Randomly pick up 4*n_ins combinations of arguments
for k in xrange(4*n_ins): for k in xrange(4 * n_ins):
inp = [] inp = []
for inp_nb in xrange(n_ins): for inp_nb in xrange(n_ins):
...@@ -424,9 +425,9 @@ class TestScan(unittest.TestCase): ...@@ -424,9 +425,9 @@ class TestScan(unittest.TestCase):
dict(tap=-2, use=True)], dict(tap=-2, use=True)],
[dict(tap=-4, use=False), [dict(tap=-4, use=False),
dict(tap=-2, use=True)]] dict(tap=-2, use=True)]]
for n_ins in [1,2]: for n_ins in [1, 2]:
# Randomly pick up 4*n_ins combinations of arguments # Randomly pick up 4*n_ins combinations of arguments
for k in xrange(4*n_ins): for k in xrange(4 * n_ins):
state = [] state = []
for state_nb in xrange(n_ins): for state_nb in xrange(n_ins):
pos = rng.randint(len(possible_taps_use_pairs)) pos = rng.randint(len(possible_taps_use_pairs))
...@@ -442,8 +443,8 @@ class TestScan(unittest.TestCase): ...@@ -442,8 +443,8 @@ class TestScan(unittest.TestCase):
# The test will also have to be changesd following some further # The test will also have to be changesd following some further
# restriction of scan and reduction of the number of corner cases # restriction of scan and reduction of the number of corner cases
return return
for n_outputs in [0,1,2]: for n_outputs in [0, 1, 2]:
for n_shared_updates in [0,1, 2]: for n_shared_updates in [0, 1, 2]:
for n_random_combinations in xrange(1): for n_random_combinations in xrange(1):
pos_inp = rng.randint(len(all_inputs_info)) pos_inp = rng.randint(len(all_inputs_info))
pos_st = rng.randint(len(all_states_info)) pos_st = rng.randint(len(all_states_info))
...@@ -463,8 +464,6 @@ class TestScan(unittest.TestCase): ...@@ -463,8 +464,6 @@ class TestScan(unittest.TestCase):
n_outputs=n_outputs, n_outputs=n_outputs,
n_shared_updates=n_shared_updates) n_shared_updates=n_shared_updates)
def test002_generator_one_scalar_output(self): def test002_generator_one_scalar_output(self):
# The test fails, because the `work-in-progress` ScanOp always runs in # The test fails, because the `work-in-progress` ScanOp always runs in
# place (even when told not to by DebugMode). As this op will change # place (even when told not to by DebugMode). As this op will change
...@@ -472,6 +471,7 @@ class TestScan(unittest.TestCase): ...@@ -472,6 +471,7 @@ class TestScan(unittest.TestCase):
# error is marked as KnownFailure # error is marked as KnownFailure
raise KnownFailureTest('Work-in-progress sandbox ScanOp is not fully ' raise KnownFailureTest('Work-in-progress sandbox ScanOp is not fully '
'functional yet') 'functional yet')
def f_pow2(x_tm1): def f_pow2(x_tm1):
return 2 * x_tm1 return 2 * x_tm1
...@@ -506,8 +506,10 @@ class TestScan(unittest.TestCase): ...@@ -506,8 +506,10 @@ class TestScan(unittest.TestCase):
# place (even when told not to by DebugMode). As this op will change # place (even when told not to by DebugMode). As this op will change
# soon, and it is in the sandbox and not for user consumption, the # soon, and it is in the sandbox and not for user consumption, the
# error is marked as KnownFailure # error is marked as KnownFailure
raise KnownFailureTest('Work-in-progress sandbox ScanOp is not fully ' raise KnownFailureTest('Work-in-progress sandbox ScanOp is not fully '
'functional yet') 'functional yet')
def f_rnn(u_t, x_tm1, W_in, W): def f_rnn(u_t, x_tm1, W_in, W):
return u_t * W_in + x_tm1 * W return u_t * W_in + x_tm1 * W
u = theano.tensor.vector('u') u = theano.tensor.vector('u')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论