提交 ad331e49 authored 作者: James Bergstra's avatar James Bergstra

modified Reshape to infer broadcastable flags correctly

上级 b5c4a92f
......@@ -2566,7 +2566,14 @@ class Reshape(Op):
return '%s{%s}' %(self.__class__.__name__, self.ndim)
def make_node(self, x, shp):
x = as_tensor_variable(x)
shp = as_tensor_variable(shp)
shp = as_tensor_variable(shp, ndim=1)
if not shp.dtype.startswith('int'):
raise TypeError("Shape must be integers")
assert shp.ndim == 1
if isinstance(shp, TensorConstant):
bcast = [s==1 for s in shp.data]
return gof.Apply(self, [x, shp], [tensor(x.type.dtype, bcast)])
else:
return gof.Apply(self, [x, shp], [tensor(x.type.dtype, [False]*self.ndim)])
def perform(self, node, (x, shp), (out,)):
if (len(shp) != self.ndim):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论