提交 485a1e4d authored 作者: Ian Goodfellow's avatar Ian Goodfellow

merged

...@@ -159,7 +159,10 @@ def Lop(f, wrt, eval_points, consider_constant=None, warn_type=False, ...@@ -159,7 +159,10 @@ def Lop(f, wrt, eval_points, consider_constant=None, warn_type=False,
if type(eval_points) not in (list, tuple): if type(eval_points) not in (list, tuple):
eval_points = [eval_points] eval_points = [eval_points]
if type(f) not in (list, tuple):
using_list = isinstance(f, list)
using_tuple = isinstance(f, tuple)
if not (using_list or using_tuple):
f = [f] f = [f]
inputs = gof.graph.inputs(f) inputs = gof.graph.inputs(f)
...@@ -199,8 +202,15 @@ def Lop(f, wrt, eval_points, consider_constant=None, warn_type=False, ...@@ -199,8 +202,15 @@ def Lop(f, wrt, eval_points, consider_constant=None, warn_type=False,
ret.append(zeros_like(p)) ret.append(zeros_like(p))
if len(ret) == 1: if len(ret) == 1:
return ret[0] if using_list:
return ret
elif using_tuple:
return tuple(ret)
else:
return ret[0]
else: else:
if using_tuple:
return tuple(ret)
return ret return ret
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论