提交 0e2f2cb9 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

made get_constant_value handle empty ndarray

上级 35d78258
...@@ -480,6 +480,11 @@ def get_constant_value(v): ...@@ -480,6 +480,11 @@ def get_constant_value(v):
data = v.tag.unique_value data = v.tag.unique_value
else: else:
data = v.data data = v.data
# handle case where data is numpy.array([])
if hasattr(data, 'shape') and len(data.shape) == 0 or \
__builtins__['max'](data.shape) == 0:
assert numpy.all(numpy.array([])==data)
return data
try: try:
numpy.complex(data) # works for all numeric scalars numpy.complex(data) # works for all numeric scalars
return data return data
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论