提交 bc578962 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

Merge pull request #385 from delallea/minor

Minor stuff Thanks Olivier :) Is great to have someone like you involved in the project, that is able to notice and fix all the small details.
......@@ -110,7 +110,7 @@ def get_updates_and_outputs(ls):
raise ValueError(('Scan can not parse the return value'
' of your constructive function given to scan'))
ls = list(ls)
deprication_msg = ('The return value of the lambda function'
deprecation_msg = ('The return value of the lambda function'
' has been restricted. you have to always return first the'
' outputs (if any), afterwards the updates (if any) and'
' at the end the condition')
......@@ -126,7 +126,7 @@ def get_updates_and_outputs(ls):
raise ValueError(error_msg)
elif is_updates(ls[0]):
if is_outputs(ls[1]):
raise ValueError(deprication_msg)
raise ValueError(deprecation_msg)
elif is_condition(ls[1]):
return (ls[1].condition, [], dict(ls[0]))
else:
......
......@@ -135,7 +135,7 @@ class TestScan(unittest.TestCase):
else:
shared_outs = [sh * 5 for sh in shared_vars]
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,
shared_outs))
......@@ -220,7 +220,7 @@ class TestScan(unittest.TestCase):
if to_add is not None:
shared_values = [sh * 5 + to_add for sh in shared_values]
for state in nw_states_outs:
state[step] += to_add
state[step] += to_add
for out in out_mem_buffers:
out[step] = to_add ** 2
else:
......@@ -249,7 +249,7 @@ class TestScan(unittest.TestCase):
if n_steps is not None and abs(n_steps) == 1:
all_nodes = my_f.maker.env.toposort()
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, ' go_backwards', go_backwards
......@@ -300,12 +300,14 @@ class TestScan(unittest.TestCase):
try:
assert numpy.allclose(th_out, num_out)
except:
import ipdb; ipdb.set_trace()
#import ipdb; ipdb.set_trace()
raise
for th_out, num_out in zip(shared_vars, numpy_shared):
try:
assert numpy.allclose(th_out.get_value(), num_out)
except:
import ipdb; ipdb.set_trace()
#import ipdb; ipdb.set_trace()
raise
# Scenario 2 : Loose fit (sequences longer then required)
print >>sys.stderr, ' Scenario 2. Loose shapes'
input_values = []
......@@ -319,7 +321,8 @@ class TestScan(unittest.TestCase):
if n_steps is not None:
# loose inputs make sense only when n_steps is
# defined
data = rng.uniform(size=(abs(_n_steps) + offset + pos + 1, 4))
data = rng.uniform(
size=(abs(_n_steps) + offset + pos + 1, 4))
else:
data = rng.uniform(size=(abs(_n_steps) + offset, 4))
input_values.append(data)
......@@ -400,9 +403,9 @@ class TestScan(unittest.TestCase):
[dict(tap=-2, use=True),
dict(tap=3, use=True)]]
test_nb = 0
for n_ins in [1,2]:
for n_ins in [1, 2]:
# Randomly pick up 4*n_ins combinations of arguments
for k in xrange(4*n_ins):
for k in xrange(4 * n_ins):
inp = []
for inp_nb in xrange(n_ins):
......@@ -424,9 +427,9 @@ class TestScan(unittest.TestCase):
dict(tap=-2, use=True)],
[dict(tap=-4, use=False),
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
for k in xrange(4*n_ins):
for k in xrange(4 * n_ins):
state = []
for state_nb in xrange(n_ins):
pos = rng.randint(len(possible_taps_use_pairs))
......@@ -442,8 +445,8 @@ class TestScan(unittest.TestCase):
# The test will also have to be changesd following some further
# restriction of scan and reduction of the number of corner cases
return
for n_outputs in [0,1,2]:
for n_shared_updates in [0,1, 2]:
for n_outputs in [0, 1, 2]:
for n_shared_updates in [0, 1, 2]:
for n_random_combinations in xrange(1):
pos_inp = rng.randint(len(all_inputs_info))
pos_st = rng.randint(len(all_states_info))
......@@ -463,14 +466,14 @@ class TestScan(unittest.TestCase):
n_outputs=n_outputs,
n_shared_updates=n_shared_updates)
def test002_generator_one_scalar_output(self):
# 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
# soon, and it is in the sandbox and not for user consumption, the
# error is marked as KnownFailure
raise KnownFailureTest
raise KnownFailureTest('Work-in-progress sandbox ScanOp is not fully '
'functional yet')
def f_pow2(x_tm1):
return 2 * x_tm1
......@@ -505,7 +508,10 @@ class TestScan(unittest.TestCase):
# 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
# error is marked as KnownFailure
raise KnownFailureTest
raise KnownFailureTest('Work-in-progress sandbox ScanOp is not fully '
'functional yet')
def f_rnn(u_t, x_tm1, W_in, W):
return u_t * W_in + x_tm1 * W
u = theano.tensor.vector('u')
......
......@@ -225,7 +225,7 @@ def get_updates_and_outputs(ls):
if not isinstance(ls, (list, tuple)):
raise ValueError(error_msg)
ls = list(ls)
deprication_msg = ('The return value of the lambda function'
deprecation_msg = ('The return value of the lambda function'
' has been restricted. you have to always return first the'
' outputs (if any), afterwards the updates (if any) and'
' at the end the conclusion')
......@@ -239,7 +239,7 @@ def get_updates_and_outputs(ls):
raise ValueError(error_msg)
elif is_updates(ls[0]):
if is_outputs(ls[1]):
raise ValueError(deprication_msg)
raise ValueError(deprecation_msg)
elif is_condition(ls[1]):
return (ls[1].condition, [], dict(ls[0]))
else:
......
......@@ -1571,7 +1571,7 @@ class T_Scan(unittest.TestCase):
# trng = theano.tensor.shared_randomstreams.RandomStreams(
# utt.fetch_seed())
def f_rnn_cmpl(u_t, x_tm1, W_in):
def f_rnn_cmpl(u_t, x_tm1, W_in):
trng1 = theano.tensor.shared_randomstreams.RandomStreams(123)
x_t = theano.dot(u_t, W_in) + x_tm1 + \
trng1.uniform(low=-.1, high=.1)
......@@ -2896,11 +2896,11 @@ class T_Scan(unittest.TestCase):
rng = numpy.random.RandomState(utt.fetch_seed())
# If numbers are small, the gradients with respect to x are small
# and the numeric differentiation becomes unstable.
# To fix this issue I unsure we are sampling numbers larger in
# absolute value than 1
# To fix this issue I ensure we are sampling numbers larger in
# absolute value than 1.
v_x = numpy.array(rng.uniform(size=(5, 2, 2), low=1., high=3.),
dtype=theano.config.floatX)
# making some entries to be negative
# Making some entries to be negative.
pos = rng.uniform(size=(5, 2, 2), low=0., high=1) < .5
v_x[pos] = -1 * v_x[pos]
v_w = numpy.array(rng.uniform(size=(2, 2), low=1., high=3.),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论