提交 82ea557d authored 作者: Ian Goodfellow's avatar Ian Goodfellow

changed Lop to have list-in, list-out behavior

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