提交 23ccd2ac authored 作者: Frederic Bastien's avatar Frederic Bastien

Code refactoring to create variable only once.

上级 b0115248
...@@ -4464,14 +4464,14 @@ class Reshape(Op): ...@@ -4464,14 +4464,14 @@ class Reshape(Op):
return [requ] return [requ]
else: else:
new_dims = [node.inputs[1][i] for i in xrange(self.ndim)] new_dims = [node.inputs[1][i] for i in xrange(self.ndim)]
# since new_dims has one negative value (-1), the # since new_dims can have negative value (-1), the
# multiplication of all values should be negated # multiplication of all values should be negated
# to give a positive value. # to give a positive value.
# To avoid optimization complexity, we avoid checking # To avoid optimization complexity, we avoid checking
# for the case when there are two or more '-1' values. # for the case when there are two or more '-1' values.
rest_size = (mul(*ishapes[0]) // -mul(*new_dims))
return [tuple([switch(eq(new_dims[i], -1), return [tuple([switch(eq(new_dims[i], -1),
theano.tensor.mul(*ishapes[0]) // rest_size,
(-theano.tensor.mul(*new_dims)),
new_dims[i]) new_dims[i])
for i in xrange(self.ndim)])] for i in xrange(self.ndim)])]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论