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