提交 5f5f63e1 authored 作者: nouiz's avatar nouiz

Merge pull request #432 from pascanur/Lop_useless_restriction

Removed useless constraint
...@@ -347,10 +347,6 @@ def Lop(f, wrt, eval_points, consider_constant=None, warn_type=False, ...@@ -347,10 +347,6 @@ def Lop(f, wrt, eval_points, consider_constant=None, warn_type=False,
if consider_constant is None: if consider_constant is None:
consider_constant = [] consider_constant = []
if not isinstance(f, Variable):
raise TypeError(('In Lop(), cost argument should be '
'a Variable.'), f)
if type(eval_points) not in (list, tuple): if type(eval_points) not in (list, tuple):
eval_points = [eval_points] eval_points = [eval_points]
......
...@@ -311,3 +311,33 @@ class test_RopLop(RopLop_checker): ...@@ -311,3 +311,33 @@ class test_RopLop(RopLop_checker):
pass pass
assert not success assert not success
def test_multiple_outputs(self):
m = tensor.matrix('m')
v = tensor.vector('v')
m_ = tensor.matrix('m_')
v_ = tensor.vector('v_')
mval = self.rng.uniform(size=(3,7)).astype(theano.config.floatX)
vval = self.rng.uniform(size=(7,)).astype(theano.config.floatX)
m_val = self.rng.uniform(size=(3,7)).astype(theano.config.floatX)
v_val = self.rng.uniform(size=(7,)).astype(theano.config.floatX)
rop_out1 = tensor.Rop([m, v, m+v], [m, v], [m_, v_])
assert isinstance(rop_out1, list)
assert len(rop_out1) == 3
rop_out2 = tensor.Rop((m, v, m+v), [m, v], [m_, v_])
assert isinstance(rop_out2, tuple)
assert len(rop_out2) == 3
lop_out1 = tensor.Lop([m, v, m+v], (m, v), [m_, v_])
assert isinstance(lop_out1, tuple)
assert len(lop_out1) == 2
lop_out2 = tensor.Lop((m, v, m+v), [m, v], [m_, v_])
assert isinstance(lop_out2, list)
assert len(lop_out2) == 2
all_outs = []
for o in rop_out1, rop_out2, lop_out1, lop_out2:
all_outs.extend(o)
f = theano.function([m, v, m_, v_], all_outs)
f(mval, vval, m_val, v_val)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论