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

merge

......@@ -101,6 +101,11 @@ class DimShuffle(Op):
self.new_order = new_order
self.inplace = inplace
for i in xrange(len(new_order)-1):
j = new_order[i]
if j != 'x' and j in new_order[i+1:]:
raise ValueError("The same input dimension may not appear twice in the list of output dimensions", (new_order))
# list of dimensions of the input to drop
self.drop = []
i2j = {} # this maps i before dropping dimensions to j after dropping dimensions so self.shuffle can be set properly later on
......
......@@ -3342,6 +3342,20 @@ def test_unalign():
if not should_raise:
raise Exception("Theano raised an exception when none was expected")
def test_dimshuffle_duplicate():
x = theano.tensor.vector()
success = False
try:
y = theano.tensor.DimShuffle((False, ), (0, 0))(x)
except ValueError, e:
assert str(e).find("may not appear twice") != -1
success = True
assert success
if __name__ == '__main__':
if 1:
unittest.main()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论