提交 76e6de02 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

simplify handling of known_grads

上级 a931005f
......@@ -438,6 +438,9 @@ def grad(cost, wrt, consider_constant=None,
# build a dict mapping var to the gradient of cost with respect to var
grad_dict = {}
if known_grads is None:
known_grads = {}
# The gradient of the cost is 1 unless specified otherwise by known_grads.
if cost is not None:
if cost in known_grads:
......@@ -457,7 +460,6 @@ def grad(cost, wrt, consider_constant=None,
grad_dict[cost] = g_cost
if known_grads is not None:
for var in known_grads:
g_var = known_grads[var]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论