提交 5fb0c235 authored 作者: AlexLamb's avatar AlexLamb

Changed != None to "is not None". Made dictionary wrapping function more concise. Added unit test

上级 6e28e1b2
...@@ -677,16 +677,16 @@ class Function(object): ...@@ -677,16 +677,16 @@ class Function(object):
return outputs[0] return outputs[0]
else: else:
if self.output_keys != None: if self.output_keys is not None:
outputDict = {} outputDict = {}
assert len(self.output_keys) == len(outputs) assert len(self.output_keys) == len(outputs)
for i in range(0, len(self.output_keys)): #for i in range(0, len(self.output_keys)):
outputDict[self.output_keys[i]] = outputs[i] # outputDict[self.output_keys[i]] = outputs[i]
outputs = outputDict return dict(itertools.izip(self.output_keys, outputs))
return outputs return outputs
......
...@@ -80,3 +80,16 @@ class dictionary_output_checker(unittest.TestCase): ...@@ -80,3 +80,16 @@ class dictionary_output_checker(unittest.TestCase):
assert result[0] == 47.0 assert result[0] == 47.0
assert result[1] == 420.0 assert result[1] == 420.0
def test_output_list(self):
x = T.scalar('x')
f = theano.function([x], outputs = [x * 3, x * 2, x * 4, x])
result = f(5.0)
assert result[0] == 15.0
assert result[1] == 10.0
assert result[2] == 20.0
assert result[3] == 5.0
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论