提交 755cfd65 authored 作者: Frederic Bastien's avatar Frederic Bastien

'simplified following recode review comment that was wrong as the code was too complex.'

上级 a5ac1425
...@@ -3372,14 +3372,14 @@ def stack(*tensors): ...@@ -3372,14 +3372,14 @@ def stack(*tensors):
raise Exception('theano.tensor.stack(*tensors) must have at least one parameter') raise Exception('theano.tensor.stack(*tensors) must have at least one parameter')
# If all tensors are scalars of the same type, call make_vector. # If all tensors are scalars of the same type, call make_vector.
# It makes the graph simpler, by not adding DimShuffles and Rebroadcasts # It makes the graph simpler, by not adding DimShuffles and Rebroadcasts
if isinstance(tensors[0], (numpy.number, float, int, python_complex)):
tensors=list(tensors) # Why this is not an optimization?
tensors[0]=as_tensor_variable(tensors[0]) # This make the graph less canonicalized(more type need to be understood by all optimization)
if numpy.all([isinstance(t, (numpy.number, float, int, python_complex))#in case their is direct int # DebugMode can't detect error in this code as it is not in an optimization.
or (isinstance(t, Variable) and if numpy.all([isinstance(t, (numpy.number, float, int, python_complex)) or #in case their is direct int
(isinstance(t, Variable) and
isinstance(t.type, TensorType) and isinstance(t.type, TensorType) and
t.ndim==0 and t.ndim==0)
t.type.__class__==tensors[0].type.__class__)
for t in tensors]): for t in tensors]):
tensors = map(as_tensor_variable,tensors)#in case their is direct int tensors = map(as_tensor_variable,tensors)#in case their is direct int
dtype = scal.upcast(*[i.dtype for i in tensors]) dtype = scal.upcast(*[i.dtype for i in tensors])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论