提交 52812079 authored 作者: Frederic Bastien's avatar Frederic Bastien 提交者: sentient07

Build simpler graph.

上级 61099c6f
...@@ -2354,6 +2354,8 @@ def zeros(shape, dtype=None): ...@@ -2354,6 +2354,8 @@ def zeros(shape, dtype=None):
shape = [shape] shape = [shape]
if dtype is None: if dtype is None:
dtype = config.floatX dtype = config.floatX
if len(shape) == 0:
return constant(0.0, dtype=dtype)
return alloc(numpy.array(0, dtype=dtype), *shape) return alloc(numpy.array(0, dtype=dtype), *shape)
...@@ -2365,6 +2367,8 @@ def ones(shape, dtype=None): ...@@ -2365,6 +2367,8 @@ def ones(shape, dtype=None):
shape = [shape] shape = [shape]
if dtype is None: if dtype is None:
dtype = config.floatX dtype = config.floatX
if len(shape) == 0:
return constant(1.0, dtype=dtype)
return alloc(numpy.array(1, dtype=dtype), *shape) return alloc(numpy.array(1, dtype=dtype), *shape)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论